The |> operator passes the result of the left expression as the first argument of the right function:
|>
fn double(x: int) -> int { x * 2 } fn add_one(x: int) -> int { x + 1 } // Equivalent to add_one(double(5)) let result = 5 |> double() |> add_one() print(result) // 11
Goal: Use pipe to calculate: (10 + 5) * 2 - 1 = 29. Implement the functions add_five, double and sub_one.
(10 + 5) * 2 - 1 = 29
add_five
double
sub_one
Run the code to see the output
9 results