Skip to content

Commit

Permalink
Merge branch 'curryRight_' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomek Wiszniewski committed May 4, 2015
2 parents 3f55946 + 22d0ceb commit 52cc4a9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ PRs are welcome!
- [pipe](#pipe)
- [shave](#shave)
- [curry2,3,4](#curry234)
- [curryRight2](#curryright2)
- [uncurry2,3,4](#uncurry234)
- [flip](#flip)
- [implode](#implode)
Expand Down Expand Up @@ -375,6 +376,22 @@ gβ(1)(2, 3)(4); // => 3
gβ(1, 2)(3)(4); // => 3
```

### curryRight2

Curry a function from the right – split its parameters into 2 lists. Apply the second list of parameters first, without changing the order within the lists.

```js
const curryRight2 = require('1-liners/curryRight2');

const g = (a, b, c, d) => a + b * c - d;
g(1, 2, 3, 4); // => 3

const gλ = curryRight2(g);
gλ(4)(1, 2, 3); // => 3
gλ(3, 4)(1, 2); // => 3
gλ(2, 3, 4)(1); // => 3
```

### uncurry2,3,4

Uncurry a function – collapse 2, 3 or 4 lists of parameters into one.
Expand Down
1 change: 1 addition & 0 deletions module/curryRight2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (f) => (...a) => (...b) => f(...b, ...a);
20 changes: 20 additions & 0 deletions tests/curryRight2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {equal} from 'assert';
import curryRight2 from '../curryRight2';

test('#curryRight2', () => {
const g = (a, b, c, d) => a + b * c - d;
const = curryRight2(g);

equal(
(4)(1, 2, 3),
3
);
equal(
(3, 4)(1, 2),
3
);
equal(
(2, 3, 4)(1),
3
);
});

0 comments on commit 52cc4a9

Please sign in to comment.