import { join } from "./String.ts"; import { defaultArg, some, value as value_1, Option } from "./Option.ts"; import { IComparer, IEqualityComparer, disposeSafe, isArrayLike, MutableArray, Exception, IDisposable, defaultOf, toIterator, getEnumerator, IEnumerator, compare, structuralHash, equals } from "./Util.ts"; import { float64, int32 } from "./Int32.ts"; import { Record } from "./Types.ts"; import { class_type, record_type, option_type, TypeInfo } from "./Reflection.ts"; import { SR_inputSequenceTooLong, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_notEnoughElements, SR_differentLengths, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.ts"; import { KeyNotFoundException_$ctor_Z721C83C5 } from "./System.Collections.Generic.ts"; import { randomSampleBy as randomSampleBy_1, randomChoicesBy as randomChoicesBy_1, randomChoiceBy as randomChoiceBy_1, randomShuffleInPlaceBy, transpose as transpose_1, splitInto as splitInto_1, windowed as windowed_1, pairwise as pairwise_1, chunkBySize as chunkBySize_1, map as map_1, permute as permute_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, scanBack as scanBack_1, item as item_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, setItem, fill } from "./Array.ts"; import { nonSeeded } from "./Random.ts"; export class FSharpList extends Record implements Iterable { readonly head: T; tail: Option>; constructor(head: T, tail: Option>) { super(); this.head = head; this.tail = tail; } toString(): string { const xs: FSharpList = this; return ("[" + join("; ", xs)) + "]"; } Equals(other: any): boolean { const xs: FSharpList = this; if (xs === other) { return true; } else if (other instanceof FSharpList) { const ys = other as FSharpList; const loop = (xs_1_mut: FSharpList, ys_1_mut: FSharpList): boolean => { loop: while (true) { const xs_1: FSharpList = xs_1_mut, ys_1: FSharpList = ys_1_mut; const matchValue: Option> = xs_1.tail; const matchValue_1: Option> = ys_1.tail; if (matchValue != null) { if (matchValue_1 != null) { const xt: FSharpList = value_1(matchValue); const yt: FSharpList = value_1(matchValue_1); if (equals(xs_1.head, ys_1.head)) { xs_1_mut = xt; ys_1_mut = yt; continue loop; } else { return false; } } else { return false; } } else if (matchValue_1 != null) { return false; } else { return true; } break; } }; return loop(xs, ys); } else { return false; } } GetHashCode(): int32 { const xs: FSharpList = this; const loop = (i_mut: int32, h_mut: int32, xs_1_mut: FSharpList): int32 => { loop: while (true) { const i: int32 = i_mut, h: int32 = h_mut, xs_1: FSharpList = xs_1_mut; const matchValue: Option> = xs_1.tail; if (matchValue != null) { const t: FSharpList = value_1(matchValue); if (i > 18) { return h | 0; } else { i_mut = (i + 1); h_mut = (((h << 1) + structuralHash(xs_1.head)) + (631 * i)); xs_1_mut = t; continue loop; } } else { return h | 0; } break; } }; return loop(0, 0, xs) | 0; } toJSON(): any { const this$: FSharpList = this; return Array.from(this$); } CompareTo(other: any): int32 { const xs: FSharpList = this; if (other instanceof FSharpList) { const ys = other as FSharpList; const loop = (xs_1_mut: FSharpList, ys_1_mut: FSharpList): int32 => { loop: while (true) { const xs_1: FSharpList = xs_1_mut, ys_1: FSharpList = ys_1_mut; const matchValue: Option> = xs_1.tail; const matchValue_1: Option> = ys_1.tail; if (matchValue != null) { if (matchValue_1 != null) { const xt: FSharpList = value_1(matchValue); const yt: FSharpList = value_1(matchValue_1); const c: int32 = compare(xs_1.head, ys_1.head) | 0; if (c === 0) { xs_1_mut = xt; ys_1_mut = yt; continue loop; } else { return c | 0; } } else { return 1; } } else if (matchValue_1 != null) { return -1; } else { return 0; } break; } }; return loop(xs, ys) | 0; } else { return 1; } } GetEnumerator(): IEnumerator { const xs: FSharpList = this; return ListEnumerator$1_$ctor_3002E699(xs); } [Symbol.iterator](): Iterator { return toIterator(getEnumerator(this)); } "System.Collections.IEnumerable.GetEnumerator"(): IEnumerator { const xs: FSharpList = this; return getEnumerator(xs); } } export function FSharpList_$reflection(gen0: TypeInfo): TypeInfo { return record_type("ListModule.FSharpList", [gen0], FSharpList, () => [["head", gen0], ["tail", option_type(FSharpList_$reflection(gen0))]]); } export class ListEnumerator$1 implements IEnumerator, IDisposable { readonly xs: FSharpList; it: FSharpList; current: T; constructor(xs: FSharpList) { this.xs = xs; this.it = this.xs; this.current = defaultOf(); } "System.Collections.Generic.IEnumerator`1.get_Current"(): T { const _: ListEnumerator$1 = this; return _.current; } "System.Collections.IEnumerator.get_Current"(): any { const _: ListEnumerator$1 = this; return _.current; } "System.Collections.IEnumerator.MoveNext"(): boolean { const _: ListEnumerator$1 = this; const matchValue: Option> = _.it.tail; if (matchValue != null) { const t: FSharpList = value_1(matchValue); _.current = _.it.head; _.it = t; return true; } else { return false; } } "System.Collections.IEnumerator.Reset"(): void { const _: ListEnumerator$1 = this; _.it = _.xs; _.current = defaultOf(); } Dispose(): void { } } export function ListEnumerator$1_$reflection(gen0: TypeInfo): TypeInfo { return class_type("ListModule.ListEnumerator`1", [gen0], ListEnumerator$1); } export function ListEnumerator$1_$ctor_3002E699(xs: FSharpList): ListEnumerator$1 { return new ListEnumerator$1(xs); } export function FSharpList_get_Empty(): FSharpList { return new FSharpList(defaultOf(), undefined); } export function FSharpList_Cons_305B8EAC(x: T, xs: FSharpList): FSharpList { return new FSharpList(x, xs); } export function FSharpList__get_IsEmpty(xs: FSharpList): boolean { return xs.tail == null; } export function FSharpList__get_Length(xs: FSharpList): int32 { const loop = (i_mut: int32, xs_1_mut: FSharpList): int32 => { loop: while (true) { const i: int32 = i_mut, xs_1: FSharpList = xs_1_mut; const matchValue: Option> = xs_1.tail; if (matchValue != null) { i_mut = (i + 1); xs_1_mut = value_1(matchValue); continue loop; } else { return i | 0; } break; } }; return loop(0, xs) | 0; } export function FSharpList__get_Head(xs: FSharpList): T { const matchValue: Option> = xs.tail; if (matchValue != null) { return xs.head; } else { throw new Exception((SR_inputWasEmpty + "\\nParameter name: ") + "list"); } } export function FSharpList__get_Tail(xs: FSharpList): FSharpList { const matchValue: Option> = xs.tail; if (matchValue != null) { return value_1(matchValue); } else { throw new Exception((SR_inputWasEmpty + "\\nParameter name: ") + "list"); } } export function FSharpList__get_Item_Z524259A4(xs: FSharpList, index: int32): T { const loop = (i_mut: int32, xs_1_mut: FSharpList): T => { loop: while (true) { const i: int32 = i_mut, xs_1: FSharpList = xs_1_mut; const matchValue: Option> = xs_1.tail; if (matchValue != null) { if (i === index) { return xs_1.head; } else { i_mut = (i + 1); xs_1_mut = value_1(matchValue); continue loop; } } else { throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index"); } break; } }; return loop(0, xs); } export function indexNotFound<$a>(): $a { throw KeyNotFoundException_$ctor_Z721C83C5(SR_keyNotFoundAlt); } export function empty<$a>(): FSharpList<$a> { return FSharpList_get_Empty<$a>(); } export function cons(x: T, xs: FSharpList): FSharpList { return FSharpList_Cons_305B8EAC(x, xs); } export function singleton<$a>(x: $a): FSharpList<$a> { return FSharpList_Cons_305B8EAC<$a>(x, FSharpList_get_Empty<$a>()); } export function isEmpty(xs: FSharpList): boolean { return FSharpList__get_IsEmpty(xs); } export function length(xs: FSharpList): int32 { return FSharpList__get_Length(xs) | 0; } export function head(xs: FSharpList): T { return FSharpList__get_Head(xs); } export function tryHead(xs: FSharpList): Option { if (FSharpList__get_IsEmpty(xs)) { return undefined; } else { return some(FSharpList__get_Head(xs)); } } export function tail(xs: FSharpList): FSharpList { return FSharpList__get_Tail(xs); } export function tryLast(xs_mut: FSharpList): Option { tryLast: while (true) { const xs: FSharpList = xs_mut; if (FSharpList__get_IsEmpty(xs)) { return undefined; } else { const t: FSharpList = FSharpList__get_Tail(xs); if (FSharpList__get_IsEmpty(t)) { return some(FSharpList__get_Head(xs)); } else { xs_mut = t; continue tryLast; } } break; } } export function last(xs: FSharpList): T { const matchValue: Option = tryLast(xs); if (matchValue == null) { throw new Exception(SR_inputWasEmpty); } else { return value_1(matchValue); } } export function compareWith(comparer: ((arg0: T, arg1: T) => int32), xs: FSharpList, ys: FSharpList): int32 { const loop = (xs_1_mut: FSharpList, ys_1_mut: FSharpList): int32 => { loop: while (true) { const xs_1: FSharpList = xs_1_mut, ys_1: FSharpList = ys_1_mut; const matchValue: boolean = FSharpList__get_IsEmpty(xs_1); const matchValue_1: boolean = FSharpList__get_IsEmpty(ys_1); if (matchValue) { if (matchValue_1) { return 0; } else { return -1; } } else if (matchValue_1) { return 1; } else { const c: int32 = comparer(FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1)) | 0; if (c === 0) { xs_1_mut = FSharpList__get_Tail(xs_1); ys_1_mut = FSharpList__get_Tail(ys_1); continue loop; } else { return c | 0; } } break; } }; return loop(xs, ys) | 0; } export function toArray(xs: FSharpList): MutableArray { const len: int32 = FSharpList__get_Length(xs) | 0; const res: MutableArray = fill(new Array(len), 0, len, null); const loop = (i_mut: int32, xs_1_mut: FSharpList): void => { loop: while (true) { const i: int32 = i_mut, xs_1: FSharpList = xs_1_mut; if (!FSharpList__get_IsEmpty(xs_1)) { setItem(res, i, FSharpList__get_Head(xs_1)); i_mut = (i + 1); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; loop(0, xs); return res; } export function fold(folder: ((arg0: State, arg1: T) => State), state: State, xs: FSharpList): State { let acc: State = state; let xs_1: FSharpList = xs; while (!FSharpList__get_IsEmpty(xs_1)) { acc = folder(acc, head(xs_1)); xs_1 = FSharpList__get_Tail(xs_1); } return acc; } export function reverse(xs: FSharpList): FSharpList { return fold>((acc: FSharpList, x: T): FSharpList => FSharpList_Cons_305B8EAC(x, acc), FSharpList_get_Empty(), xs); } export function foldBack(folder: ((arg0: T, arg1: State) => State), xs: FSharpList, state: State): State { return foldBack_1(folder, toArray(xs), state); } export function foldIndexed(folder: ((arg0: int32, arg1: State, arg2: T) => State), state: State, xs: FSharpList): State { const loop = (i_mut: int32, acc_mut: State, xs_1_mut: FSharpList): State => { loop: while (true) { const i: int32 = i_mut, acc: State = acc_mut, xs_1: FSharpList = xs_1_mut; if (FSharpList__get_IsEmpty(xs_1)) { return acc; } else { i_mut = (i + 1); acc_mut = folder(i, acc, FSharpList__get_Head(xs_1)); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; return loop(0, state, xs); } export function fold2(folder: ((arg0: State, arg1: T1, arg2: T2) => State), state: State, xs: FSharpList, ys: FSharpList): State { let acc: State = state; let xs_1: FSharpList = xs; let ys_1: FSharpList = ys; while (!FSharpList__get_IsEmpty(xs_1) && !FSharpList__get_IsEmpty(ys_1)) { acc = folder(acc, FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1)); xs_1 = FSharpList__get_Tail(xs_1); ys_1 = FSharpList__get_Tail(ys_1); } return acc; } export function foldBack2(folder: ((arg0: T1, arg1: T2, arg2: State) => State), xs: FSharpList, ys: FSharpList, state: State): State { return foldBack2_1(folder, toArray(xs), toArray(ys), state); } export function unfold(generator: ((arg0: State) => Option<[T, State]>), state: State): FSharpList { const loop = (acc_mut: State, node_mut: FSharpList): FSharpList => { loop: while (true) { const acc: State = acc_mut, node: FSharpList = node_mut; let t: FSharpList = undefined as any; const matchValue: Option<[T, State]> = generator(acc); if (matchValue != null) { acc_mut = value_1(matchValue)[1]; node_mut = ((t = (new FSharpList(value_1(matchValue)[0], undefined)), (node.tail = t, t))); continue loop; } else { return node; } break; } }; const root: FSharpList = FSharpList_get_Empty(); const node_1: FSharpList = loop(state, root); const t_2: FSharpList = FSharpList_get_Empty(); node_1.tail = t_2; return FSharpList__get_Tail(root); } export function iterate<$a>(action: ((arg0: $a) => void), xs: FSharpList<$a>): void { fold<$a, void>((unitVar: void, x: $a): void => { action(x); }, undefined, xs); } export function iterate2<$a, $b>(action: ((arg0: $a, arg1: $b) => void), xs: FSharpList<$a>, ys: FSharpList<$b>): void { fold2<$a, $b, void>((unitVar: void, x: $a, y: $b): void => { action(x, y); }, undefined, xs, ys); } export function iterateIndexed<$a>(action: ((arg0: int32, arg1: $a) => void), xs: FSharpList<$a>): void { fold<$a, int32>((i: int32, x: $a): int32 => { action(i, x); return (i + 1) | 0; }, 0, xs); } export function iterateIndexed2<$a, $b>(action: ((arg0: int32, arg1: $a, arg2: $b) => void), xs: FSharpList<$a>, ys: FSharpList<$b>): void { fold2<$a, $b, int32>((i: int32, x: $a, y: $b): int32 => { action(i, x, y); return (i + 1) | 0; }, 0, xs, ys); } export function toSeq(xs: FSharpList): Iterable { return xs; } export function ofArrayWithTail(xs: MutableArray, tail_1: FSharpList): FSharpList { let res: FSharpList = tail_1; for (let i: int32 = xs.length - 1; i >= 0; i--) { res = FSharpList_Cons_305B8EAC(item_1(i, xs), res); } return res; } export function ofArray(xs: MutableArray): FSharpList { return ofArrayWithTail(xs, FSharpList_get_Empty()); } export function ofSeq(xs: Iterable): FSharpList { if (isArrayLike(xs)) { return ofArray(xs); } else if (xs instanceof FSharpList) { return xs; } else { const root: FSharpList = FSharpList_get_Empty(); let node: FSharpList = root; const enumerator: IEnumerator = getEnumerator(xs); try { while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { let xs_3: FSharpList = (undefined as any), t: FSharpList = (undefined as any); const x: T = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"](); node = ((xs_3 = node, (t = (new FSharpList(x, undefined)), (xs_3.tail = t, t)))); } } finally { disposeSafe(enumerator as IDisposable); } const xs_5: FSharpList = node; const t_2: FSharpList = FSharpList_get_Empty(); xs_5.tail = t_2; return FSharpList__get_Tail(root); } } export function concat(lists: Iterable>): FSharpList { const root: FSharpList = FSharpList_get_Empty(); let node: FSharpList = root; const action = (xs: FSharpList): void => { node = fold>((acc: FSharpList, x: T): FSharpList => { const t: FSharpList = new FSharpList(x, undefined); acc.tail = t; return t; }, node, xs); }; if (isArrayLike(lists)) { const xs_3: MutableArray> = lists; xs_3.forEach(action); } else if (lists instanceof FSharpList) { iterate>(action, lists); } else { const enumerator: IEnumerator> = getEnumerator(lists); try { while (enumerator["System.Collections.IEnumerator.MoveNext"]()) { action(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()); } } finally { disposeSafe(enumerator as IDisposable); } } const xs_6: FSharpList = node; const t_2: FSharpList = FSharpList_get_Empty(); xs_6.tail = t_2; return FSharpList__get_Tail(root); } export function scan(folder: ((arg0: State, arg1: T) => State), state: State, xs: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); let node: FSharpList; const t: FSharpList = new FSharpList(state, undefined); root.tail = t; node = t; let acc: State = state; let xs_3: FSharpList = xs; while (!FSharpList__get_IsEmpty(xs_3)) { let xs_4: FSharpList = (undefined as any), t_2: FSharpList = (undefined as any); acc = folder(acc, FSharpList__get_Head(xs_3)); node = ((xs_4 = node, (t_2 = (new FSharpList(acc, undefined)), (xs_4.tail = t_2, t_2)))); xs_3 = FSharpList__get_Tail(xs_3); } const xs_6: FSharpList = node; const t_4: FSharpList = FSharpList_get_Empty(); xs_6.tail = t_4; return FSharpList__get_Tail(root); } export function scanBack(folder: ((arg0: T, arg1: State) => State), xs: FSharpList, state: State): FSharpList { return ofArray(scanBack_1(folder, toArray(xs), state)); } export function append(xs: FSharpList, ys: FSharpList): FSharpList { return fold>((acc: FSharpList, x: T): FSharpList => FSharpList_Cons_305B8EAC(x, acc), ys, reverse(xs)); } export function collect(mapping: ((arg0: T) => FSharpList), xs: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); let node: FSharpList = root; let ys: FSharpList = xs; while (!FSharpList__get_IsEmpty(ys)) { let zs: FSharpList = mapping(FSharpList__get_Head(ys)); while (!FSharpList__get_IsEmpty(zs)) { let xs_1: FSharpList = (undefined as any), t: FSharpList = (undefined as any); node = ((xs_1 = node, (t = (new FSharpList(FSharpList__get_Head(zs), undefined)), (xs_1.tail = t, t)))); zs = FSharpList__get_Tail(zs); } ys = FSharpList__get_Tail(ys); } const xs_3: FSharpList = node; const t_2: FSharpList = FSharpList_get_Empty(); xs_3.tail = t_2; return FSharpList__get_Tail(root); } export function mapIndexed(mapping: ((arg0: int32, arg1: T) => U), xs: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = foldIndexed, T>((i: int32, acc: FSharpList, x: T): FSharpList => { const t: FSharpList = new FSharpList(mapping(i, x), undefined); acc.tail = t; return t; }, root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function map(mapping: ((arg0: T) => U), xs: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = fold>((acc: FSharpList, x: T): FSharpList => { const t: FSharpList = new FSharpList(mapping(x), undefined); acc.tail = t; return t; }, root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function indexed<$a>(xs: FSharpList<$a>): FSharpList<[int32, $a]> { return mapIndexed<$a, [int32, $a]>((i: int32, x: $a): [int32, $a] => ([i, x] as [int32, $a]), xs); } export function map2(mapping: ((arg0: T1, arg1: T2) => U), xs: FSharpList, ys: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = fold2>((acc: FSharpList, x: T1, y: T2): FSharpList => { const t: FSharpList = new FSharpList(mapping(x, y), undefined); acc.tail = t; return t; }, root, xs, ys); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function mapIndexed2(mapping: ((arg0: int32, arg1: T1, arg2: T2) => U), xs: FSharpList, ys: FSharpList): FSharpList { const loop = (i_mut: int32, acc_mut: FSharpList, xs_1_mut: FSharpList, ys_1_mut: FSharpList): FSharpList => { loop: while (true) { const i: int32 = i_mut, acc: FSharpList = acc_mut, xs_1: FSharpList = xs_1_mut, ys_1: FSharpList = ys_1_mut; let t: FSharpList = undefined as any; if (FSharpList__get_IsEmpty(xs_1) ? true : FSharpList__get_IsEmpty(ys_1)) { return acc; } else { i_mut = (i + 1); acc_mut = ((t = (new FSharpList(mapping(i, FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1)), undefined)), (acc.tail = t, t))); xs_1_mut = FSharpList__get_Tail(xs_1); ys_1_mut = FSharpList__get_Tail(ys_1); continue loop; } break; } }; const root: FSharpList = FSharpList_get_Empty(); const node_1: FSharpList = loop(0, root, xs, ys); const t_2: FSharpList = FSharpList_get_Empty(); node_1.tail = t_2; return FSharpList__get_Tail(root); } export function map3(mapping: ((arg0: T1, arg1: T2, arg2: T3) => U), xs: FSharpList, ys: FSharpList, zs: FSharpList): FSharpList { const loop = (acc_mut: FSharpList, xs_1_mut: FSharpList, ys_1_mut: FSharpList, zs_1_mut: FSharpList): FSharpList => { loop: while (true) { const acc: FSharpList = acc_mut, xs_1: FSharpList = xs_1_mut, ys_1: FSharpList = ys_1_mut, zs_1: FSharpList = zs_1_mut; let t: FSharpList = undefined as any; if ((FSharpList__get_IsEmpty(xs_1) ? true : FSharpList__get_IsEmpty(ys_1)) ? true : FSharpList__get_IsEmpty(zs_1)) { return acc; } else { acc_mut = ((t = (new FSharpList(mapping(FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1), FSharpList__get_Head(zs_1)), undefined)), (acc.tail = t, t))); xs_1_mut = FSharpList__get_Tail(xs_1); ys_1_mut = FSharpList__get_Tail(ys_1); zs_1_mut = FSharpList__get_Tail(zs_1); continue loop; } break; } }; const root: FSharpList = FSharpList_get_Empty(); const node_1: FSharpList = loop(root, xs, ys, zs); const t_2: FSharpList = FSharpList_get_Empty(); node_1.tail = t_2; return FSharpList__get_Tail(root); } export function mapFold(mapping: ((arg0: State, arg1: T) => [Result, State]), state: State, xs: FSharpList): [FSharpList, State] { const root: FSharpList = FSharpList_get_Empty(); const patternInput_1: [FSharpList, State] = fold, State]>((tupledArg: [FSharpList, State], x: T): [FSharpList, State] => { let t: FSharpList = undefined as any; const patternInput: [Result, State] = mapping(tupledArg[1], x); return [(t = (new FSharpList(patternInput[0], undefined)), (tupledArg[0].tail = t, t)), patternInput[1]] as [FSharpList, State]; }, [root, state] as [FSharpList, State], xs); const t_2: FSharpList = FSharpList_get_Empty(); patternInput_1[0].tail = t_2; return [FSharpList__get_Tail(root), patternInput_1[1]] as [FSharpList, State]; } export function mapFoldBack(mapping: ((arg0: T, arg1: State) => [Result, State]), xs: FSharpList, state: State): [FSharpList, State] { return mapFold((acc: State, x: T): [Result, State] => mapping(x, acc), state, reverse(xs)); } export function tryPick(f: ((arg0: T) => Option<$a>), xs: FSharpList): Option<$a> { const loop = (xs_1_mut: FSharpList): Option<$a> => { loop: while (true) { const xs_1: FSharpList = xs_1_mut; if (FSharpList__get_IsEmpty(xs_1)) { return undefined; } else { const matchValue: Option<$a> = f(FSharpList__get_Head(xs_1)); if (matchValue == null) { xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } else { return matchValue; } } break; } }; return loop(xs); } export function pick<$a, $b>(f: ((arg0: $a) => Option<$b>), xs: FSharpList<$a>): $b { const matchValue: Option<$b> = tryPick<$a, $b>(f, xs); if (matchValue == null) { return indexNotFound<$b>(); } else { return value_1(matchValue); } } export function tryFind<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): Option<$a> { return tryPick<$a, $a>((x: $a): Option<$a> => (f(x) ? some(x) : undefined), xs); } export function find<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): $a { const matchValue: Option<$a> = tryFind<$a>(f, xs); if (matchValue == null) { return indexNotFound<$a>(); } else { return value_1(matchValue); } } export function tryFindBack<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): Option<$a> { return tryFindBack_1<$a>(f, toArray<$a>(xs)); } export function findBack<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): $a { const matchValue: Option<$a> = tryFindBack<$a>(f, xs); if (matchValue == null) { return indexNotFound<$a>(); } else { return value_1(matchValue); } } export function tryFindIndex(f: ((arg0: T) => boolean), xs: FSharpList): Option { const loop = (i_mut: int32, xs_1_mut: FSharpList): Option => { loop: while (true) { const i: int32 = i_mut, xs_1: FSharpList = xs_1_mut; if (FSharpList__get_IsEmpty(xs_1)) { return undefined; } else if (f(FSharpList__get_Head(xs_1))) { return i; } else { i_mut = (i + 1); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; return loop(0, xs); } export function findIndex<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): int32 { const matchValue: Option = tryFindIndex<$a>(f, xs); if (matchValue == null) { indexNotFound(); return -1; } else { return value_1(matchValue) | 0; } } export function tryFindIndexBack<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): Option { return tryFindIndexBack_1<$a>(f, toArray<$a>(xs)); } export function findIndexBack<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): int32 { const matchValue: Option = tryFindIndexBack<$a>(f, xs); if (matchValue == null) { indexNotFound(); return -1; } else { return value_1(matchValue) | 0; } } export function tryItem(n: int32, xs: FSharpList): Option { const loop = (i_mut: int32, xs_1_mut: FSharpList): Option => { loop: while (true) { const i: int32 = i_mut, xs_1: FSharpList = xs_1_mut; if (FSharpList__get_IsEmpty(xs_1)) { return undefined; } else if (i === n) { return some(FSharpList__get_Head(xs_1)); } else { i_mut = (i + 1); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; return loop(0, xs); } export function item(n: int32, xs: FSharpList): T { return FSharpList__get_Item_Z524259A4(xs, n); } export function filter(f: ((arg0: T) => boolean), xs: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = fold>((acc: FSharpList, x: T): FSharpList => { if (f(x)) { const t: FSharpList = new FSharpList(x, undefined); acc.tail = t; return t; } else { return acc; } }, root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function partition(f: ((arg0: T) => boolean), xs: FSharpList): [FSharpList, FSharpList] { const matchValue: FSharpList = FSharpList_get_Empty(); const root2: FSharpList = FSharpList_get_Empty(); const root1: FSharpList = matchValue; const patternInput_1: [FSharpList, FSharpList] = fold, FSharpList]>((tupledArg: [FSharpList, FSharpList], x: T): [FSharpList, FSharpList] => { let t: FSharpList = (undefined as any), t_2: FSharpList = (undefined as any); const lacc: FSharpList = tupledArg[0]; const racc: FSharpList = tupledArg[1]; if (f(x)) { return [(t = (new FSharpList(x, undefined)), (lacc.tail = t, t)), racc] as [FSharpList, FSharpList]; } else { return [lacc, (t_2 = (new FSharpList(x, undefined)), (racc.tail = t_2, t_2))] as [FSharpList, FSharpList]; } }, [root1, root2] as [FSharpList, FSharpList], xs); const t_4: FSharpList = FSharpList_get_Empty(); patternInput_1[0].tail = t_4; const t_5: FSharpList = FSharpList_get_Empty(); patternInput_1[1].tail = t_5; return [FSharpList__get_Tail(root1), FSharpList__get_Tail(root2)] as [FSharpList, FSharpList]; } export function choose(f: ((arg0: T) => Option), xs: FSharpList): FSharpList { const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = fold>((acc: FSharpList, x: T): FSharpList => { const matchValue: Option = f(x); if (matchValue == null) { return acc; } else { const t: FSharpList = new FSharpList(value_1(matchValue), undefined); acc.tail = t; return t; } }, root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function contains(value: T, xs: FSharpList, eq: IEqualityComparer): boolean { return tryFindIndex((v: T): boolean => eq.Equals(value, v), xs) != null; } export function initialize(n: int32, f: ((arg0: int32) => T)): FSharpList { const root: FSharpList = FSharpList_get_Empty(); let node: FSharpList = root; for (let i = 0; i <= (n - 1); i++) { let xs: FSharpList = (undefined as any), t: FSharpList = (undefined as any); node = ((xs = node, (t = (new FSharpList(f(i), undefined)), (xs.tail = t, t)))); } const xs_2: FSharpList = node; const t_2: FSharpList = FSharpList_get_Empty(); xs_2.tail = t_2; return FSharpList__get_Tail(root); } export function replicate<$a>(n: int32, x: $a): FSharpList<$a> { return initialize<$a>(n, (_arg: int32): $a => x); } export function reduce(f: ((arg0: T, arg1: T) => T), xs: FSharpList): T { if (FSharpList__get_IsEmpty(xs)) { throw new Exception(SR_inputWasEmpty); } else { return fold(f, head(xs), tail(xs)); } } export function reduceBack(f: ((arg0: T, arg1: T) => T), xs: FSharpList): T { if (FSharpList__get_IsEmpty(xs)) { throw new Exception(SR_inputWasEmpty); } else { return foldBack(f, tail(xs), head(xs)); } } export function forAll<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): boolean { return fold<$a, boolean>((acc: boolean, x: $a): boolean => (acc && f(x)), true, xs); } export function forAll2<$a, $b>(f: ((arg0: $a, arg1: $b) => boolean), xs: FSharpList<$a>, ys: FSharpList<$b>): boolean { return fold2<$a, $b, boolean>((acc: boolean, x: $a, y: $b): boolean => (acc && f(x, y)), true, xs, ys); } export function exists<$a>(f: ((arg0: $a) => boolean), xs: FSharpList<$a>): boolean { return tryFindIndex<$a>(f, xs) != null; } export function exists2(f_mut: ((arg0: T1, arg1: T2) => boolean), xs_mut: FSharpList, ys_mut: FSharpList): boolean { exists2: while (true) { const f: ((arg0: T1, arg1: T2) => boolean) = f_mut, xs: FSharpList = xs_mut, ys: FSharpList = ys_mut; const matchValue: boolean = FSharpList__get_IsEmpty(xs); const matchValue_1: boolean = FSharpList__get_IsEmpty(ys); let matchResult: int32 = undefined as any; if (matchValue) { if (matchValue_1) { matchResult = 0; } else { matchResult = 2; } } else if (matchValue_1) { matchResult = 2; } else { matchResult = 1; } switch (matchResult) { case 0: return false; case 1: if (f(FSharpList__get_Head(xs), FSharpList__get_Head(ys))) { return true; } else { f_mut = f; xs_mut = FSharpList__get_Tail(xs); ys_mut = FSharpList__get_Tail(ys); continue exists2; } default: throw new Exception((SR_differentLengths + "\\nParameter name: ") + "list2"); } break; } } export function unzip<$a, $b>(xs: FSharpList<[$a, $b]>): [FSharpList<$a>, FSharpList<$b>] { return foldBack<[$a, $b], [FSharpList<$a>, FSharpList<$b>]>((tupledArg: [$a, $b], tupledArg_1: [FSharpList<$a>, FSharpList<$b>]): [FSharpList<$a>, FSharpList<$b>] => ([FSharpList_Cons_305B8EAC<$a>(tupledArg[0], tupledArg_1[0]), FSharpList_Cons_305B8EAC<$b>(tupledArg[1], tupledArg_1[1])] as [FSharpList<$a>, FSharpList<$b>]), xs, [FSharpList_get_Empty<$a>(), FSharpList_get_Empty<$b>()] as [FSharpList<$a>, FSharpList<$b>]); } export function unzip3<$a, $b, $c>(xs: FSharpList<[$a, $b, $c]>): [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>] { return foldBack<[$a, $b, $c], [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>]>((tupledArg: [$a, $b, $c], tupledArg_1: [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>]): [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>] => ([FSharpList_Cons_305B8EAC<$a>(tupledArg[0], tupledArg_1[0]), FSharpList_Cons_305B8EAC<$b>(tupledArg[1], tupledArg_1[1]), FSharpList_Cons_305B8EAC<$c>(tupledArg[2], tupledArg_1[2])] as [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>]), xs, [FSharpList_get_Empty<$a>(), FSharpList_get_Empty<$b>(), FSharpList_get_Empty<$c>()] as [FSharpList<$a>, FSharpList<$b>, FSharpList<$c>]); } export function zip<$a, $b>(xs: FSharpList<$a>, ys: FSharpList<$b>): FSharpList<[$a, $b]> { return map2<$a, $b, [$a, $b]>((x: $a, y: $b): [$a, $b] => ([x, y] as [$a, $b]), xs, ys); } export function zip3<$a, $b, $c>(xs: FSharpList<$a>, ys: FSharpList<$b>, zs: FSharpList<$c>): FSharpList<[$a, $b, $c]> { return map3<$a, $b, $c, [$a, $b, $c]>((x: $a, y: $b, z: $c): [$a, $b, $c] => ([x, y, z] as [$a, $b, $c]), xs, ys, zs); } export function sortWith(comparer: ((arg0: T, arg1: T) => int32), xs: FSharpList): FSharpList { const arr: MutableArray = toArray(xs); arr.sort(comparer); return ofArray(arr); } export function sort(xs: FSharpList, comparer: IComparer): FSharpList { return sortWith((x: T, y: T): int32 => (comparer.Compare(x, y) | 0), xs); } export function sortBy(projection: ((arg0: T) => U), xs: FSharpList, comparer: IComparer): FSharpList { return sortWith((x: T, y: T): int32 => (comparer.Compare(projection(x), projection(y)) | 0), xs); } export function sortDescending(xs: FSharpList, comparer: IComparer): FSharpList { return sortWith((x: T, y: T): int32 => ((comparer.Compare(x, y) * -1) | 0), xs); } export function sortByDescending(projection: ((arg0: T) => U), xs: FSharpList, comparer: IComparer): FSharpList { return sortWith((x: T, y: T): int32 => ((comparer.Compare(projection(x), projection(y)) * -1) | 0), xs); } export function sum(xs: FSharpList, adder: any): T { return fold((acc: T, x: T): T => adder.Add(acc, x), adder.GetZero(), xs); } export function sumBy(f: ((arg0: T) => U), xs: FSharpList, adder: any): U { return fold((acc: U, x: T): U => adder.Add(acc, f(x)), adder.GetZero(), xs); } export function maxBy(projection: ((arg0: T) => U), xs: FSharpList, comparer: IComparer): T { return reduce((x: T, y: T): T => ((comparer.Compare(projection(y), projection(x)) > 0) ? y : x), xs); } export function max(xs: FSharpList, comparer: IComparer): T { return reduce((x: T, y: T): T => ((comparer.Compare(y, x) > 0) ? y : x), xs); } export function minBy(projection: ((arg0: T) => U), xs: FSharpList, comparer: IComparer): T { return reduce((x: T, y: T): T => ((comparer.Compare(projection(y), projection(x)) > 0) ? x : y), xs); } export function min(xs: FSharpList, comparer: IComparer): T { return reduce((x: T, y: T): T => ((comparer.Compare(y, x) > 0) ? x : y), xs); } export function average(xs: FSharpList, averager: any): T { let count = 0; const total: T = fold((acc: T, x: T): T => { count = ((count + 1) | 0); return averager.Add(acc, x); }, averager.GetZero(), xs); return averager.DivideByInt(total, count); } export function averageBy(f: ((arg0: T) => U), xs: FSharpList, averager: any): U { let count = 0; const total: U = fold((acc: U, x: T): U => { count = ((count + 1) | 0); return averager.Add(acc, f(x)); }, averager.GetZero(), xs); return averager.DivideByInt(total, count); } export function permute(f: ((arg0: int32) => int32), xs: FSharpList): FSharpList { return ofArray(permute_1(f, toArray(xs))); } export function chunkBySize(chunkSize: int32, xs: FSharpList): FSharpList> { return ofArray>(map_1, FSharpList>(ofArray, chunkBySize_1(chunkSize, toArray(xs)))); } export function allPairs(xs: FSharpList, ys: FSharpList): FSharpList<[T1, T2]> { const root: FSharpList<[T1, T2]> = FSharpList_get_Empty<[T1, T2]>(); let node: FSharpList<[T1, T2]> = root; iterate((x: T1): void => { iterate((y: T2): void => { let xs_1: FSharpList<[T1, T2]> = (undefined as any), t: FSharpList<[T1, T2]> = (undefined as any); node = ((xs_1 = node, (t = (new FSharpList([x, y] as [T1, T2], undefined)), (xs_1.tail = t, t)))); }, ys); }, xs); const xs_3: FSharpList<[T1, T2]> = node; const t_2: FSharpList<[T1, T2]> = FSharpList_get_Empty<[T1, T2]>(); xs_3.tail = t_2; return FSharpList__get_Tail<[T1, T2]>(root); } export function skip(count_mut: int32, xs_mut: FSharpList): FSharpList { skip: while (true) { const count: int32 = count_mut, xs: FSharpList = xs_mut; if (count <= 0) { return xs; } else if (FSharpList__get_IsEmpty(xs)) { throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "list"); } else { count_mut = (count - 1); xs_mut = FSharpList__get_Tail(xs); continue skip; } break; } } export function skipWhile(predicate_mut: ((arg0: T) => boolean), xs_mut: FSharpList): FSharpList { skipWhile: while (true) { const predicate: ((arg0: T) => boolean) = predicate_mut, xs: FSharpList = xs_mut; if (FSharpList__get_IsEmpty(xs)) { return xs; } else if (!predicate(FSharpList__get_Head(xs))) { return xs; } else { predicate_mut = predicate; xs_mut = FSharpList__get_Tail(xs); continue skipWhile; } break; } } export function take(count: int32, xs: FSharpList): FSharpList { if (count < 0) { throw new Exception((SR_inputMustBeNonNegative + "\\nParameter name: ") + "count"); } const loop = (i_mut: int32, acc_mut: FSharpList, xs_1_mut: FSharpList): FSharpList => { loop: while (true) { const i: int32 = i_mut, acc: FSharpList = acc_mut, xs_1: FSharpList = xs_1_mut; let t: FSharpList = undefined as any; if (i <= 0) { return acc; } else if (FSharpList__get_IsEmpty(xs_1)) { throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "list"); } else { i_mut = (i - 1); acc_mut = ((t = (new FSharpList(FSharpList__get_Head(xs_1), undefined)), (acc.tail = t, t))); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = loop(count, root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function takeWhile(predicate: ((arg0: T) => boolean), xs: FSharpList): FSharpList { const loop = (acc_mut: FSharpList, xs_1_mut: FSharpList): FSharpList => { loop: while (true) { const acc: FSharpList = acc_mut, xs_1: FSharpList = xs_1_mut; let t: FSharpList = undefined as any; if (FSharpList__get_IsEmpty(xs_1)) { return acc; } else if (!predicate(FSharpList__get_Head(xs_1))) { return acc; } else { acc_mut = ((t = (new FSharpList(FSharpList__get_Head(xs_1), undefined)), (acc.tail = t, t))); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = loop(root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function truncate(count: int32, xs: FSharpList): FSharpList { const loop = (i_mut: int32, acc_mut: FSharpList, xs_1_mut: FSharpList): FSharpList => { loop: while (true) { const i: int32 = i_mut, acc: FSharpList = acc_mut, xs_1: FSharpList = xs_1_mut; let t: FSharpList = undefined as any; if (i <= 0) { return acc; } else if (FSharpList__get_IsEmpty(xs_1)) { return acc; } else { i_mut = (i - 1); acc_mut = ((t = (new FSharpList(FSharpList__get_Head(xs_1), undefined)), (acc.tail = t, t))); xs_1_mut = FSharpList__get_Tail(xs_1); continue loop; } break; } }; const root: FSharpList = FSharpList_get_Empty(); const node: FSharpList = loop(count, root, xs); const t_2: FSharpList = FSharpList_get_Empty(); node.tail = t_2; return FSharpList__get_Tail(root); } export function getSlice(startIndex: Option, endIndex: Option, xs: FSharpList): FSharpList { const len: int32 = length(xs) | 0; let startIndex_1: int32; const index: int32 = defaultArg(startIndex, 0) | 0; startIndex_1 = ((index < 0) ? 0 : index); let endIndex_1: int32; const index_1: int32 = defaultArg(endIndex, len - 1) | 0; endIndex_1 = ((index_1 >= len) ? (len - 1) : index_1); if (endIndex_1 < startIndex_1) { return FSharpList_get_Empty(); } else { return take((endIndex_1 - startIndex_1) + 1, skip(startIndex_1, xs)); } } export function splitAt(index: int32, xs: FSharpList): [FSharpList, FSharpList] { if (index < 0) { throw new Exception((SR_inputMustBeNonNegative + "\\nParameter name: ") + "index"); } if (index > FSharpList__get_Length(xs)) { throw new Exception((SR_notEnoughElements + "\\nParameter name: ") + "index"); } return [take(index, xs), skip(index, xs)] as [FSharpList, FSharpList]; } export function exactlyOne(xs: FSharpList): T { if (FSharpList__get_IsEmpty(xs)) { throw new Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "list"); } else if (FSharpList__get_IsEmpty(FSharpList__get_Tail(xs))) { return FSharpList__get_Head(xs); } else { throw new Exception((SR_inputSequenceTooLong + "\\nParameter name: ") + "list"); } } export function tryExactlyOne(xs: FSharpList): Option { if (!FSharpList__get_IsEmpty(xs) && FSharpList__get_IsEmpty(FSharpList__get_Tail(xs))) { return some(FSharpList__get_Head(xs)); } else { return undefined; } } export function where(predicate: ((arg0: T) => boolean), xs: FSharpList): FSharpList { return filter(predicate, xs); } export function pairwise(xs: FSharpList): FSharpList<[T, T]> { return ofArray<[T, T]>(pairwise_1(toArray(xs))); } export function windowed(windowSize: int32, xs: FSharpList): FSharpList> { return ofArray>(map_1, FSharpList>(ofArray, windowed_1(windowSize, toArray(xs)))); } export function splitInto(chunks: int32, xs: FSharpList): FSharpList> { return ofArray>(map_1, FSharpList>(ofArray, splitInto_1(chunks, toArray(xs)))); } export function transpose(lists: Iterable>): FSharpList> { return ofArray>(map_1, FSharpList>(ofArray, transpose_1(map_1, MutableArray>(toArray, Array.from(lists))))); } export function insertAt(index: int32, y: T, xs: FSharpList): FSharpList { let i = -1; let isDone = false; const result: FSharpList = fold>((acc: FSharpList, x: T): FSharpList => { i = ((i + 1) | 0); if (i === index) { isDone = true; return FSharpList_Cons_305B8EAC(x, FSharpList_Cons_305B8EAC(y, acc)); } else { return FSharpList_Cons_305B8EAC(x, acc); } }, FSharpList_get_Empty(), xs); return reverse(isDone ? result : (((i + 1) === index) ? FSharpList_Cons_305B8EAC(y, result) : (() => { throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index"); })())); } export function insertManyAt(index: int32, ys: Iterable, xs: FSharpList): FSharpList { let i = -1; let isDone = false; const ys_1: FSharpList = ofSeq(ys); const result: FSharpList = fold>((acc: FSharpList, x: T): FSharpList => { i = ((i + 1) | 0); if (i === index) { isDone = true; return FSharpList_Cons_305B8EAC(x, append(ys_1, acc)); } else { return FSharpList_Cons_305B8EAC(x, acc); } }, FSharpList_get_Empty(), xs); return reverse(isDone ? result : (((i + 1) === index) ? append(ys_1, result) : (() => { throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index"); })())); } export function removeAt(index: int32, xs: FSharpList): FSharpList { let i = -1; let isDone = false; const ys: FSharpList = filter((_arg: T): boolean => { i = ((i + 1) | 0); if (i === index) { isDone = true; return false; } else { return true; } }, xs); if (!isDone) { throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index"); } return ys; } export function removeManyAt(index: int32, count: int32, xs: FSharpList): FSharpList { let i = -1; let status = -1; const ys: FSharpList = filter((_arg: T): boolean => { i = ((i + 1) | 0); if (i === index) { status = 0; return false; } else if (i > index) { if (i < (index + count)) { return false; } else { status = 1; return true; } } else { return true; } }, xs); const status_1: int32 = (((status === 0) && ((i + 1) === (index + count))) ? 1 : status) | 0; if (status_1 < 1) { throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + ((status_1 < 0) ? "index" : "count")); } return ys; } export function updateAt(index: int32, y: T, xs: FSharpList): FSharpList { let isDone = false; const ys: FSharpList = mapIndexed((i: int32, x: T): T => { if (i === index) { isDone = true; return y; } else { return x; } }, xs); if (!isDone) { throw new Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index"); } return ys; } export function randomShuffleBy(randomizer: (() => float64), xs: FSharpList): FSharpList { const arr: MutableArray = toArray(xs); randomShuffleInPlaceBy(randomizer, arr); return ofArray(arr); } export function randomShuffleWith(random: any, xs: FSharpList): FSharpList { return randomShuffleBy((): float64 => random.NextDouble(), xs); } export function randomShuffle(xs: FSharpList): FSharpList { return randomShuffleWith(nonSeeded(), xs); } export function randomChoiceBy(randomizer: (() => float64), xs: FSharpList): T { return randomChoiceBy_1(randomizer, toArray(xs)); } export function randomChoiceWith(random: any, xs: FSharpList): T { return randomChoiceBy((): float64 => random.NextDouble(), xs); } export function randomChoice(xs: FSharpList): T { return randomChoiceWith(nonSeeded(), xs); } export function randomChoicesBy(randomizer: (() => float64), count: int32, xs: FSharpList): FSharpList { return ofArray(randomChoicesBy_1(randomizer, count, toArray(xs))); } export function randomChoicesWith(random: any, count: int32, xs: FSharpList): FSharpList { return randomChoicesBy((): float64 => random.NextDouble(), count, xs); } export function randomChoices(count: int32, xs: FSharpList): FSharpList { return randomChoicesWith(nonSeeded(), count, xs); } export function randomSampleBy(randomizer: (() => float64), count: int32, xs: FSharpList): FSharpList { return ofArray(randomSampleBy_1(randomizer, count, toArray(xs))); } export function randomSampleWith(random: any, count: int32, xs: FSharpList): FSharpList { return randomSampleBy((): float64 => random.NextDouble(), count, xs); } export function randomSample(count: int32, xs: FSharpList): FSharpList { return randomSampleWith(nonSeeded(), count, xs); }