Partial function application: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
m (→‎{{header|Perl}}: future-proof for 5.36, explicit :prototype)
Line 1,833: Line 1,833:
=={{header|Perl}}==
=={{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.
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(&) {
<syntaxhighlight lang="perl">sub fs :prototype(&) {
my $func = shift;
my $func = shift;
sub { map $func->($_), @_ }
sub { map $func->($_), @_ }
}
}


sub double($) { shift() * 2 }
sub double :prototype($) { shift() * 2 }
sub square($) { shift() ** 2 }
sub square :prototype($) { shift() ** 2 }


my $fs_double = fs(\&double);
my $fs_double = fs(\&double);