Skip to content

Instantly share code, notes, and snippets.

@waldogit
waldogit / curry.spec.ts
Last active April 18, 2016 20:29
variadic curry supporting 1 to 4 arguments, curried currying and partial application, in Typescript
const concatter4 = (a:string, b:string , c:string , d: string) => `a: ${a} b: ${b} c: ${c} d: ${d}`;
it('expect _ to allow partially applying an N4 curried function', () => {
expect(curry(concatter4)(_, 'b','c','d')('a')).toEqual('a: a b: b c: c d: d');
});
it('expect _, _ to allow partially applying an N4 curried function', () => {
expect(curry(concatter4)(_, _,'c','d')('a')('b')).toEqual('a: a b: b c: c d: d');
});
it('expect _, x, _ to allow partially applying an N4 curried function', () => {
expect(curry(concatter4)(_, 'b', _,'d')('a', 'c')).toEqual('a: a b: b c: c d: d');
});