casualjavascript/haskell-in-es6

flip should only reverse the first two arguments

Closed this issue · 0 comments

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

Wouldn't this implementation reverse the args instead of flip the first two?

function flip (f) {
  return (...args) => f(...args.reverse());
}

const foo = (a, b, c) => [a, b, c];

const test = flip(foo); // ['c', 'b', 'a'] -- should return ['b','a','c']