Logo

Programming-Idioms

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

Idiom #37 Currying

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

fn add(a: u32, b: u32) -> u32 {
    a + b
}

let add5 = move |x| add(5, x);
 
(def rev-key #(update %2 %1 reverse))

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

New implementation...
< >
Adrian