Monads/List monad: Difference between revisions

Content added Content deleted
Line 355: Line 355:


=={{header|Julia}}==
=={{header|Julia}}==
Julia uses the function bind for binding a channel to a task, but this can be imported and overloaded.
Julia uses the function bind for binding a channel to a task, but this can be imported and overloaded.
The |> syntax in Julia can also be used to chain functions taking one argument.
<lang julia>julia> unit(v) = [v...]
<lang julia>julia> unit(v) = [v...]
unit (generic function with 1 method)
unit (generic function with 1 method)
Line 371: Line 372:


julia> bind(bind(unit([2, 3, 4]), f1), f2)
julia> bind(bind(unit([2, 3, 4]), f1), f2)
3-element Array{Int64,1}:
6
8
10

julia> unit([2, 3, 4]) .|> f1 .|> f2
3-element Array{Int64,1}:
3-element Array{Int64,1}:
6
6