1.0.1 • Published 5 years ago
flip-curried v1.0.1
flip-curried
Flip the arguments of a curried function (like Haskell's flip
).
Installation
npm install --save flip-curried
Usage
flip(f)(b)(a)
is equivalent to f(a)(b)
.
import { flip } from "flip-curried";
const n = 3;
const xs = [1, 2, 3, 4, 5];
take(n)(xs); // [1, 2, 3]
flip(take)(xs)(n); // [1, 2, 3]
function take<A>(n: number): (xs: Array<A>) => Array<A> {
return xs => xs.slice(0, n);
}
TypeScript
Declarations are included.