Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 462 Bytes

README.md

File metadata and controls

16 lines (13 loc) · 462 Bytes

Flip arguments in curried functions

Write a function flip that takes as input a function f in curried form and returns a new function that works as f but takes its arguments in the opposite order.

The function must have the following type:

flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c

Here are some unit tests:

let sub x y = x - y;;
let flipped_sub = flip sub;;
assert (flipped_sub 3 10 = 7);;
assert (flipped_sub 10 3 = -7);;