Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #37 Currying

Transform a function that takes multiple arguments into a function for which some of the arguments are preset.

sub curry {
   my ($func, $fixed_arg) = @_;
   return sub {
      $func->($fixed_arg, @_);
   }
}
(def add5 (partial + 5))

New implementation...
< >
Adrian