Data::...::Curry(3pm)
β¨ NAME β¨
Data::Util::Curry β she curries functions and methods π
like it's literally her whole personality and honestly? slay.
π SYNOPSIS π
okay bestie, here's the vibe:
use feature 'say';
use Data::Util qw(curry);
sub sum{
my $total = 0;
for my $x(@_){
$total += $x;
}
return $total;
}
# placeholder "\0" indicates a subscript of the arguments
say curry(\&add, \0, 42)->(10); # 52
# placeholder "*_" indicates all the arguments
say curry(\&add, *_)->(1 .. 10); # 55
# two subscripts and the rest of the arguments
say curry(\&add, *_, \1, \0)->(1 .. 5); # 3 + 4 + 5 + 1 + 2
not me noticing she definessumand then curries\&addπ we simply do not ask questions, the code is copied exactly as it is, no cap.
so the placeholders are the whole moment here:
\0= a subscript of the arguments (arg number zero, bestie)*_= all the arguments π
πΈ DESCRIPTION πΈ
(todo)
yeah. that's it. that's the description. iconic minimalism honestly, main character energy, she said "not today" π
π¦ EXAMPLES π¦
π Currying Functions
curry(\&f, \0, 2)->(1); # f(1, 2)
curry(\&f, 3, \0)->(4); # f(3, 4)
curry(\&f, *_)->(5, 6); # f(5, 6)
curry(\&f, \0, \1, *_)->(1, 2, 3, 4); # f(1, 2, 3, 4)
curry(\&f, *_, \0, \1)->(1, 2, 3, 4); # f(3, 4, 1, 2)
see how the placeholders slide around and the args fall into them? it's giving choreography π the order you write the placeholders in is the order your arguments land, periodt.
π Currying Methods
curry($obj, 'something', *_)->(1, 2); # $obj->something(1, 2)
curry($obj, 'something',
foo => \0,
bar => \1)->(1, 2); # $obj->something(foo => 1, bar => 2)
curry(\0, 'something', \1)->($obj, 42); # $obj->something(42)
curry($obj, \0, *_)->('something', 1, 2); # $obj->something(1, 2)
ngl this is the part where it eats π₯ even the object and the method name can be placeholders. pass the receiver later, pass the method name later, whatever β she'll figure it out and it will be correct, iykyk β¨
π Argument Semantics
sub incr{ $_[0]++ }
my $i = 0;
curry(\&incr, \0)->($i); # $i++
curry(\&incr, *_)->($i); # $i++
curry(\&incr, $i)->(); # $i++
all three of these do the exact same thing on purpose, bestie: $i++ every single time π«Ά whether the arg is a subscript, all-the-args, or just plain passed in β the aliasing carries through. obsessed.
β SEE ALSO β
Data::Util.
go read that one too, she's the whole family π§
and that's the page!! written by the Perl documentation girlies, shipped as perl v5.42.3, dated 2026-08-19, and yes the manual name stamped on the corner is Data::...::Curry(3pm) π mwah, go curry something, ily π
π¦ where this page comes from
- ubuntu stonking: libdata-util-perl 0.67-1build7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms