Partial function application: Difference between revisions
Content added Content deleted
(CoffeeScript) |
|||
Line 500: | Line 500: | ||
fsf1(array): [4, 8, 12, 16] |
fsf1(array): [4, 8, 12, 16] |
||
fsf2(array): [4, 16, 36, 64]</pre> |
fsf2(array): [4, 16, 36, 64]</pre> |
||
=={{header|Mathematica}}== |
|||
<lang Mathematica>fs[f_, s_] := Map[f, s] |
|||
f1 [n_] := n*2 |
|||
f2 [n_] := n^2 |
|||
fsf1[s_] := fs[f1, s] |
|||
fsf2[s_] := fs[f2, s]</lang> |
|||
Example usage: |
|||
<pre>fsf1[{0, 1, 2, 3}] |
|||
->{0, 2, 4, 6} |
|||
fsf2[{0, 1, 2, 3}] |
|||
->{0, 1, 4, 9} |
|||
fsf1[{2, 4, 6, 8}] |
|||
->{4, 8, 12, 16} |
|||
fsf2[{2, 4, 6, 8}] |
|||
->{4, 16, 36, 64}</pre> |
|||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |