Pipelines¶
Pipelines (|>
) are an alternative syntax for function application:
Example
"Hello there"
|> String.split(" ")
|> List.length
|> #(_ + 1)
// is the same as:
List.length(String.split(" ", "Hello there")) + 1
The general form is:
value |> function // ==
function(value)
value |> function(initial, arguments) // ==
function(initial, arguments, value)
|>
is left-associative:
In case you want to provide an argument to a function on a different position than the last, use the hole shorthand: