Partial function application: Difference between revisions

→‎{{header|Perl 6}}: add more explanation
(→‎{{header|Perl 6}}: you partially apply arguments or curry a function)
(→‎{{header|Perl 6}}: add more explanation)
Line 369:
 
=={{header|Perl 6}}==
All Code objects have the .assuming method, which partially applies its arguments. For both type safety reasons and parsing sanity reasons we do not believe in implicit currying by leaving out arguments. Also, people can understand "assuming" without being steeped in FP culture.
<lang perl6>sub fs ( Code $f, @s ) { @s.map: { .$f } }
 
Line 386:
4 8 12 16
4 16 36 64</pre>
Here we curry the function using named arguments, but positional notation is also supported. (Named arguments are more general in the sense that they do not require you to curry your arguments from left-to-right.)
 
The <tt>*+2</tt> is also a form of partial application in Perl&nbsp;6. In this case we curry the <tt>infix:<+></tt> function with a second argument of 2. That is, the star (known as the "whatever" star) indicates which argument <em>not</em> to apply. The explicit star allows us to avoid syntactic ambiguity in whether to expect a term or an infix operator; such self-clocking code contributes to better error messages when things go wrong.
 
=={{header|PicoLisp}}==
Anonymous user