in reply to Currying--useful examples?
and now I would have both of my arrays incremented by 1 across all their elements. Better yet, I could combine it with closures to create incrementors by an arbitrary value:# contrived my $incAll = map { $_++ }; my @data = return_some_numbers(); my @data2 = return_some_other_numbers(); $incAll->(@data); $incAll->(@data2);
In my own experience, I use currying and partial invokation extensively in Haskell which has native syntactic support for them, but so far I have not really come across them in my own Perl work.sub makeIncr { my $incr = $_[0]; return map { $_ += $incr }; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Currying--useful examples?
by tsee (Curate) on Jan 11, 2007 at 08:34 UTC |