Partial function application: Difference between revisions
m
→{{header|Perl}}: future-proof for 5.36, explicit :prototype
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36, explicit :prototype) |
||
Line 1,833:
=={{header|Perl}}==
Note: this is written according to my understanding of the task spec and the discussion page; it doesn't seem a consensus was reached regarding what counts as a "partial" yet.
<syntaxhighlight lang="perl">sub fs :prototype(&) {
my $func = shift;
sub { map $func->($_), @_ }
}
sub double :prototype($) { shift() * 2 }
sub square :prototype($) { shift() ** 2 }
my $fs_double = fs(\&double);
|