Function flip

Source
pub fn flip<'a, A, B, C, F, G>(f: F) -> impl Fn(B) -> Box<dyn Fn(A) -> C + 'a>
where B: Clone + 'a, F: Fn(A) -> G + Clone + 'a, G: Fn(B) -> C,
Expand description

Returns a version of the input curried binary function with its arguments flipped.

§Type Signature

forall a b c. (a -> b -> c) -> b -> a -> c

§Examples

use fp_library::functions::flip;

let subtract = |a| move |b| a - b;

assert_eq!(flip(subtract)(1)(0), -1); // 0 - 1 = -1