Skip to content

Commit

Permalink
issue-#57 - Progress on idiomatic curry - converted methods up to 'sr…
Browse files Browse the repository at this point in the history
…c/list/pushN'.
  • Loading branch information
elycruz committed Aug 4, 2022
1 parent 02620df commit 7320391
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/fjl/src/list/partition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {curry, CurryOf2} from "../function";
import {PredForSlice, Slice} from "../types";

export const
Expand Down Expand Up @@ -29,4 +28,5 @@ export const
return [front, back];
},

$partition = curry(partition) as CurryOf2<PredForSlice<any>, Slice<any>, [any[], any[]]>;
$partition = <T>(pred: PredForSlice<T>) =>
(list: Slice<T>): [T[], T[]] => partition(pred, list);
5 changes: 1 addition & 4 deletions packages/fjl/src/list/push.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {curry2} from "../function/curry";

export const

push = <T>(x: T, xs: T[]): T[] => {
Expand All @@ -9,6 +7,5 @@ export const

/**
* Pushes an item onto an array.
* @curried - Curried upto `2` items.
*/
$push = curry2(push);
$push = <T>(x: T) => (xs: T[]): T[] => push(x, xs);
9 changes: 4 additions & 5 deletions packages/fjl/src/list/pushN.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {curry2} from "../function";

export const

/**
Expand All @@ -14,7 +12,8 @@ export const
},

/**
* Same as `$pushN` but curried.
* @curried
* Curried version of `$pushN`.
*/
$pushN = curry2(pushN);
$pushN = <T>(xs: T[]) =>
(xs2: T, ..._xs: T[]): T[] =>
pushN(xs, xs2, ..._xs)

0 comments on commit 7320391

Please sign in to comment.