-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…lementaitons and types)and updates to tests towards 'green' tests.
- Loading branch information
Showing
27 changed files
with
173 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import {lastIndex} from './utils'; | ||
import {Slice} from "../types"; | ||
|
||
/** | ||
* Returns last item of list. | ||
*/ | ||
export const last = <T>(xs: T[]): T | undefined => xs[lastIndex(xs)]; | ||
export const last = <T>(xs: Slice<T>): T | undefined => xs[lastIndex(xs)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const length = (x: { readonly length?: number }) => x.length; | ||
import {isset} from "../object"; | ||
|
||
export const length = (x: { readonly length?: number }) => !isset(x) ? undefined : x.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import {foldl} from "./foldl"; | ||
|
||
export const | ||
|
||
/** | ||
* unzip transforms a list of pairs into a list of first components and a list of second components. | ||
* @haskellType `unzip :: [(a, b)] -> ([a], [b])` | ||
* unzip transforms a list of pairs into a tuple of lists - first list contains first components and a second contains second ones. | ||
*/ | ||
unzip = <T1, T2>(xss: [T1, T2][]): [T1[], T2[]] => { | ||
if (!xss) { | ||
throw new Error(`\`unzip\` expects a value. Received ${JSON.stringify(xss)}`); | ||
} | ||
return foldl((agg, item: [T1, T2]) => { | ||
unzip = <T1, T2>(xss: [T1, T2][]): [T1[], T2[]] => | ||
foldl((agg, item: [T1, T2]) => { | ||
if (item.length) { | ||
agg[0].push(item[0]); | ||
agg[1].push(item[1]); | ||
} | ||
return agg; | ||
}, [[], []], xss); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import {reduceUntil} from "./reduceUntil"; | ||
import {alwaysFalse} from "../../boolean/alwaysFalse"; | ||
import {ReduceOp} from "../../types"; | ||
|
||
export const | ||
|
||
/** | ||
* Reduces a "number indexable" by given reduction function (same as [].reduce but also for strings/arbitrary "number indexable" objects/etc.). | ||
*/ | ||
reduce = (op: ReduceOp, agg, xs) => | ||
reduceUntil(alwaysFalse, op, agg, xs), | ||
reduce = (op: ReduceOp, agg, xs) => { | ||
const limit = xs.length; | ||
if (!limit) return agg; | ||
let result = agg; | ||
for (let ind = 0; ind < limit; ind++) { | ||
result = op(result, xs[ind], ind, xs); | ||
} | ||
return result; | ||
}, | ||
|
||
/** | ||
* Curried `reduce` combinator. | ||
*/ | ||
$reduce = (op: ReduceOp) => agg => xs => | ||
reduceUntil(alwaysFalse, op, agg, xs) | ||
reduce(op, agg, xs) | ||
|
||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.