Monads/List monad: Difference between revisions

Content added Content deleted
(Added an informal description of the monad triple of (T, eta, mu), with notes on the particular case of List.)
Line 515: Line 515:
1 1011
1 1011
1 10 11 100 110 1100</pre>
1 10 11 100 110 1100</pre>

=={{header|Phix}}==
{{trans|Go}}
<lang Phix>function bind(sequence m, integer f)
return f(m)
end function
function unit(sequence m)
return m
end function
function increment(sequence l)
return unit(sq_add(l,1))
end function
function double(sequence l)
return unit(sq_mul(l,2))
end function
sequence m1 = unit({3, 4, 5}),
m2 = bind(bind(m1,increment),double)
printf(1,"%v -> %v\n", {m1, m2})</lang>
{{out}}
<pre>
{3,4,5} -> {8,10,12}
</pre>


=={{header|Racket}}==
=={{header|Racket}}==