Pipes
You can use pipes |>
& <|
to redirect output from an
expression as input to another.
For example, instead of writing:
val result = third_function(second_function(first_function(my_value)))
thp
You can use pipes:
val result = my_value
|> first_function
|> second_function
|> third_function
thp
Or use it to group expressions:
print <| (2 + 3 * 4) / 7
thp
TBD: How to handle piping to functions with more than 1 param
Function composition
fun add_one(x: Int) -> Int {
x + 1
}
fun times_two(x: Int) -> Int {
x * 2
}
// (Int) -> (Int)
val plus_one_times_2 = add_one >> times_two
print(plus_one_times_2(5)) // 12
thp