Partial function application: Difference between revisions
Content added Content deleted
(added Factor) |
|||
Line 678: | Line 678: | ||
[0; 1; 4; 9] |
[0; 1; 4; 9] |
||
[4; 16; 36; 64] |
[4; 16; 36; 64] |
||
</pre> |
|||
=={{header|Factor}}== |
|||
<lang>USING: kernel math prettyprint sequences ; |
|||
IN: rosetta-code.partial-function-application |
|||
ALIAS: fs map |
|||
: f1 ( n -- m ) 2 * ; |
|||
: f2 ( n -- m ) dup * ; |
|||
: fsf1 ( s -- s' ) [ f1 ] fs ; |
|||
: fsf2 ( s -- s' ) [ f2 ] fs ; |
|||
{ 0 1 2 3 } { 2 4 6 8 } |
|||
[ [ fsf1 . ] [ fsf2 . ] bi ] dup [ call ] dip call</lang> |
|||
{{out}} |
|||
<pre> |
|||
{ 0 2 4 6 } |
|||
{ 0 1 4 9 } |
|||
{ 4 8 12 16 } |
|||
{ 4 16 36 64 } |
|||
</pre> |
</pre> |
||