Partial function application: Difference between revisions

Content added Content deleted
m (added whitespace before the TOC (table of contents), added other whitespace to the task's preamble.)
No edit summary
Line 1,039: Line 1,039:


<pre>[[0, 2, 4, 6, 8], [0, 1, 4], [4, 8, 12, 16, 20, 24], [4, 16, 36, 64]]</pre>
<pre>[[0, 2, 4, 6, 8], [0, 1, 4], [4, 8, 12, 16, 20, 24], [4, 16, 36, 64]]</pre>


=={{header|Lambdatalk}}==
Lambdatalk functions are curried, therefore, partial function application is trivial. Not giving a multi-argument function all of its arguments will simply return a function that takes the remaining arguments.
<lang Scheme>
{def fs {lambda {:f} map :f}}
{def f1 {lambda {:x} {* :x 2}}}
{def f2 {lambda {:x} {pow :x 2}}}
{def fsf1 {fs f1}}
{def fsf2 {fs f2}}

{{fsf1} 0 1 2 3}
{{fsf2} 0 1 2 3}
{{fsf1} 2 4 6 8}
{{fsf2} 2 4 6 8}

Output:
0 2 4 6
0 1 4 9
4 8 12 16
4 16 36 64
</lang>


=={{header|LFE}}==
=={{header|LFE}}==