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/scanr1'.
  • Loading branch information
elycruz committed Aug 9, 2022
1 parent 7059ae3 commit b40862a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/fjl/src/list/scanl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {curry} from "../function/curry";
import {length} from "./length";
import {Slice} from "../types";

Expand Down Expand Up @@ -32,4 +31,6 @@ export const
return out;
},

$scanl = curry(scanl);
$scanl = <A, B>(fn: ScanlOp<A, B>) =>
(zero: B) =>
(xs: Slice<A>): B[] => scanl(fn, zero, xs);
4 changes: 2 additions & 2 deletions packages/fjl/src/list/scanl1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {curry} from "../function/curry";
import {scanl, ScanlOp} from "./scanl";
import {head} from "./head";
import {tail} from "./tail";
Expand All @@ -17,4 +16,5 @@ export const
* `scanl1` is a variant of `scanl` that has no starting value argument:
* `shallowCompare(scanl1(fn, [x1, x2, ...]), [x1, fn(x1, x2), ...]) // true`
*/
$scanl1 = curry(scanl1);
$scanl1 = <T>(fn: ScanlOp<T, T>) =>
(xs: Slice<T>): T[] => scanl1(fn, xs);
4 changes: 3 additions & 1 deletion packages/fjl/src/list/scanr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ export const
return out;
},

$scanr = curry(scanr);
$scanr = <A, B>(fn: ScanrOp<A, B>) =>
(zero: B) =>
(xs: Slice<A>): B[] => scanr(fn, zero, xs);
3 changes: 2 additions & 1 deletion packages/fjl/src/list/scanr1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export const
return scanr(fn, last(xs), init(xs));
},

$scanr1 = curry(scanr1);
$scanr1 = <T>(fn: ScanrOp<T, T>) =>
(xs: Slice<T>): T[] => scanr1(fn, xs);

0 comments on commit b40862a

Please sign in to comment.