-
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.
issue-#57 - Removed usages of 'Slice' type in fjl sources, except whe…
…re type is defined (needed to quickly find other usages (via IDE, etc.)).
- Loading branch information
Showing
63 changed files
with
180 additions
and
5,791 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,24 +1,23 @@ | ||
import {reduce} from "./utils/reduce"; | ||
import {append} from "./append"; | ||
import {difference} from "./difference"; | ||
import {Slice} from '../types'; | ||
|
||
export const | ||
|
||
/** | ||
* Returns the complement of list 0 and the reset of the passed in arrays. | ||
*/ | ||
complement = <T>(...arrays: Slice<T>[]): Slice<T> => { | ||
complement = <T>(...arrays: T[][]): T[] => { | ||
if (!arrays.length) return []; | ||
const [arr0] = arrays; | ||
return reduce((agg: Slice<T>, arr: Slice<T>) => | ||
append(agg, difference(arr, arr0) as Slice<T>), [], arrays) | ||
return reduce((agg: T[], arr: T[]) => | ||
append(agg, difference(arr, arr0) as T[]), [], arrays) | ||
}, | ||
|
||
/** | ||
* Returns the complement of list 0 and the reset of the passed in arrays. | ||
*/ | ||
$complement = <T>(xs1: Slice<T>) => | ||
(xs2: Slice<T>, ...arrays: Slice<T>[]): Slice<T> => complement(xs1, xs2, ...arrays) | ||
$complement = <T>(xs1: T[]) => | ||
(xs2: T[], ...arrays: T[][]): T[] => complement(xs1, xs2, ...arrays) | ||
|
||
; |
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,18 @@ | ||
import {append} from './append'; | ||
import {sliceCopy} from './utils/sliceCopy'; | ||
import {Slice} from "../types"; | ||
|
||
export const | ||
|
||
/** | ||
* Concatenates all the elements of a container of lists. | ||
*/ | ||
concat = <T>(xs: Slice<T>[]): Slice<T> => { | ||
concat = <T>(xs: T[][]): T[] => { | ||
if (!xs || !xs.length) { | ||
return [] as unknown as Slice<T>; | ||
return [] as unknown as T[]; | ||
} else if (xs.length === 1) { | ||
const item0 = xs[0]; | ||
return item0 && item0.slice ? sliceCopy(item0) : item0; | ||
} | ||
return append(...xs) as Slice<T>; | ||
return append(...xs) as T[]; | ||
} | ||
; |
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,23 +1,23 @@ | ||
import {findIndexWhereRight} from "./utils"; | ||
import {of} from "../object/of"; | ||
import {Slice, PredForSlice} from "../types"; | ||
import {sliceTo} from "./utils/sliceTo"; | ||
import {PredForArray} from "../types"; | ||
|
||
export const | ||
|
||
dropWhileEnd = <T>(p: PredForSlice<T>, list: Slice<T>): Slice<T> => { | ||
dropWhileEnd = <T>(p: PredForArray<T>, list: T[]): T[] => { | ||
const splitPoint = | ||
findIndexWhereRight( | ||
(x: T, i: number | string, xs: Slice<T>) => !p(x, i, xs), | ||
(x: T, i: number | string, xs: T[]) => !p(x, i, xs), | ||
list | ||
) as number; | ||
if (splitPoint === -1) { | ||
return of(list); | ||
} | ||
return sliceTo(splitPoint + 1, list) as Slice<T>; | ||
return sliceTo(splitPoint + 1, list) as T[]; | ||
}, | ||
|
||
$dropWhileEnd = <T>(p: PredForSlice<T>) => | ||
(list: Slice<T>): Slice<T> => dropWhileEnd(p, list) | ||
$dropWhileEnd = <T>(p: PredForArray<T>) => | ||
(list: T[]): T[] => dropWhileEnd(p, list) | ||
|
||
; |
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,14 +1,13 @@ | ||
import {indexOf} from "../platform/slice"; | ||
import {Slice} from "../types"; | ||
|
||
export const | ||
|
||
elemIndex = <T>(xs: Slice<T>, x: T): number | undefined => { | ||
elemIndex = <T>(xs: T[], x: T): number | undefined => { | ||
const foundInd = indexOf(xs, x) as number; | ||
return foundInd !== -1 ? foundInd : undefined; | ||
}, | ||
|
||
$elemIndex = <T>(xs: Slice<T>) => | ||
$elemIndex = <T>(xs: T[]) => | ||
(x: T): number | undefined => elemIndex(xs, x) | ||
; | ||
|
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,21 +1,21 @@ | ||
import {uncons} from "./uncons"; | ||
import {reduce} from "./utils/reduce"; | ||
import {ReduceOp, Slice} from "../types"; | ||
import {ReduceOp} from "../types"; | ||
|
||
export const | ||
|
||
/** | ||
* A variant of `foldl` except that this one doesn't require the starting point value. The starting point/value will be pulled | ||
* out from a copy of the container. | ||
*/ | ||
foldl1 = <T, RetT>(op: ReduceOp<T, Slice<T>, RetT>, xs: Slice<T>): RetT => { | ||
foldl1 = <T, RetT>(op: ReduceOp<T, T[], RetT>, xs: T[]): RetT => { | ||
const parts = uncons(xs); | ||
if (!parts) return; | ||
const [_head, _tail]: [T, Slice<T>] = parts; | ||
const [_head, _tail]: [T, T[]] = parts; | ||
return reduce(op, _head as unknown as RetT, _tail) as RetT; | ||
}, | ||
|
||
$foldl1 = <T, RetT>(op: ReduceOp<T, Slice<T>, RetT>) => | ||
(xs: Slice<T>): RetT => foldl1(op, xs) | ||
$foldl1 = <T, RetT>(op: ReduceOp<T, T[], RetT>) => | ||
(xs: T[]): RetT => foldl1(op, 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,19 +1,19 @@ | ||
import {unconsr} from "./unconsr"; | ||
import {reduceRight} from "./utils/reduceRight"; | ||
import {Slice, ReduceOp} from "../types"; | ||
import {ReduceOp} from "../types"; | ||
|
||
export const | ||
|
||
/** | ||
* A variant of `foldr` except that this one doesn't require the starting point/value. The starting point/value will be pulled | ||
* out from a copy of the container. | ||
*/ | ||
foldr1 = <T, ZeroT>(op: ReduceOp<T, Slice<T>, ZeroT>, xs: Slice<T>): ZeroT | [] => { | ||
foldr1 = <T, ZeroT>(op: ReduceOp<T, T[], ZeroT>, xs: T[]): ZeroT | [] => { | ||
const parts = unconsr(xs); | ||
return !parts ? [] : reduceRight(op, parts[1] as unknown as ZeroT, parts[0]); | ||
}, | ||
|
||
$foldr1 = <T, ZeroT>(op: ReduceOp<T, Slice<T>, ZeroT>) => | ||
(xs: Slice<T>): ZeroT | [] => foldr1(op, xs) | ||
$foldr1 = <T, ZeroT>(op: ReduceOp<T, T[], ZeroT>) => | ||
(xs: T[]): ZeroT | [] => foldr1(op, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import {lastIndex} from './utils'; | ||
import {Slice} from "../types"; | ||
|
||
export const | ||
/** | ||
* Returns everything except last item of list as new list. | ||
*/ | ||
init = <T>(xs: Slice<T>): Slice<T> => xs.slice(0, lastIndex(xs)); | ||
init = <T>(xs: T[]): T[] => xs.slice(0, 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
Oops, something went wrong.