in reply to [RFC: Cool Uses for Perl] A weighted randomized word generator for conlangers

Currying is when you pass these subroutine references to other functions which call them back when appropriate.

No, it's not.

Currying is if you write your function so that it can get its arguments one at a time producing a function in each except the last step. Say if you had a function add() taking two arguments, then calling it with just one would produce a function what adds that number to its one and only argument.

What you mean is a higher order function.

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re: [RFC: Cool Uses for Perl] Heavy currying: weighted randomized word generator for conlangers

Replies are listed 'Best First'.
Re^2: [RFC: Cool Uses for Perl] Heavy currying: weighted randomized word generator for conlangers
by flowdy (Scribe) on Jun 29, 2014 at 16:17 UTC
    Thank you very much for reveal my confusion. I corrected my post accordingly. To perlify your example:
    sub curriable_add { my ($first, $second) = @_; croak "first argument is undefined" if !defined $first; return $first + $second if defined $second; return sub { $first + shift }; }