Language Design: Naming Conventions
Part 5: Streaming
Published on 2022-06-08. Last updated on 2023-01-12
Name | Example | Explanation |
---|---|---|
map(fun) |
List(1, 2, 3).map(_ + 1) --> List(1, 2, 3) |
|
|
List(1, 2).mapMany(x -> List(x, x)) --> List(1, 1, 2, 2) List(1, 2).mapMany(x -> Some(x)) --> List(1, 2) List(1, 2).mapMany(x -> None) --> List() |
|
Filters
Name | Example | Explanation |
---|---|---|
first |
List(1, 2, 3).first --> Option(1) |
|
last |
List(1, 2, 3).last --> Option(3) |
|
|
List(1, 2, 3, 4).retainFirst(2) --> List(1, 2) |
|
|
List(1, 2, 3, 1).retain(_ < 2) --> List(1, 2, 1) |
|
|
List("a", "b", "c").retainIndex(_ % 2 == 0) --> List("a", "c") |
|
|
List(1, 2, 3, 1).retainWhile(_ < 3) --> List(1, 2) |
|
|
List(4, 3, 2, 4).retainUntil(_ < 3) --> List(4, 3) |
|
|
List(1, 2, 3, 4).rejectFirst(1) --> List(2, 3, 4) |
|
|
List(1, 2, 3, 1).reject(_ < 2) --> List(3) |
|
|
List("a", "b", "c").rejectIndex(_ % 2 == 0) --> List("b") |
|
|
List(2, 3, 4, 1).rejectWhile(_ < 2) --> List(3, 4, 1) |
|
|
List(3, 2, 1, 4).rejectUntil(_ < 2) --> List(1, 4) |
|
distinct |
List(1, 2, 3, 1).distinct --> List(1, 2, 3) |
|
Folds
Name | Example | Explanation |
---|---|---|
fold(fun, start) |
|
|
reduce(fun) |
|
|
combine[Monoid] |
|
|
sum[Numeric] |
List(1.0, 2.0, 3.0, 4.0).sum --> 10.0 |
|
product[Numeric] |
List(1.0, 2.0, 3.0, 4.0).product --> 24.0 |
|
average[Numeric] |
List(1.0, 2.0, 3.0, 4.0).average --> 2.5 |
|
|
|
|
|
|
|
|
|
Injects
Name | Example | Explanation |
---|---|---|
joinInner[Record] |
|
|
joinLeft[Record] |
|
|
joinRight[Record] |
|
|
joinFull[Record] |
|
|
groupBy(fun) |
|
|
partitionBy(fun) |
|
Fan-Ins
Name | Example | Explanation |
---|---|---|
concat |
|
|
interleave |
|
|
zip |
|
|
zipWithIndex |
|