First-class functions/Use numbers analogously: Difference between revisions

Content added Content deleted
(jq)
Line 734: Line 734:
# List.map2 (fun n inv -> (multiplier n inv) 0.5) coll inv_coll;;
# List.map2 (fun n inv -> (multiplier n inv) 0.5) coll inv_coll;;
- : float list = [0.5; 0.5; 0.5]</lang>
- : float list = [0.5; 0.5; 0.5]</lang>

=={{header|Oforth}}==

<lang Oforth>func: multiplier(n1, n2) { #[ n1 n2 * * ] }

func: firstClassNum
{
| x xi y yi z zi |

2.0 ->x
0.5 ->xi
4.0 ->y
0.25 ->yi
x y + ->z
x y + inv ->zi
[ x, y, z ] [ xi, yi, zi ] zipWith(#multiplier) map(#[ 0.5 swap perform ] ) println
}</lang>


=={{header|Oz}}==
=={{header|Oz}}==