Logo

Programming-Idioms

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

Idiom #37 Currying

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

adder = -> a, b { a + b }
add_two = adder.curry.(2)
add_two.(5) # => 7
(def rev-key #(update %2 %1 reverse))

(def rev-a (partial rev-key :a))

New implementation...
< >
Adrian