compostjs 0.0.11 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compost.js +34 -28
- package/dist/core.js +94 -73
- package/dist/fable_modules/fable-library-js.4.28.0/Array.d.ts +123 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Array.js +1242 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Async.d.ts +26 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Async.js +145 -0
- package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.d.ts +59 -0
- package/dist/fable_modules/fable-library-js.4.28.0/AsyncBuilder.js +183 -0
- package/dist/fable_modules/fable-library-js.4.28.0/BigInt.d.ts +115 -0
- package/dist/fable_modules/fable-library-js.4.28.0/BigInt.js +283 -0
- package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.d.ts +27 -0
- package/dist/fable_modules/fable-library-js.4.28.0/BitConverter.js +138 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Boolean.d.ts +3 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Boolean.js +21 -0
- package/dist/fable_modules/fable-library-js.4.28.0/CHANGELOG.md +100 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Char.d.ts +65 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Char.js +169 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Choice.d.ts +121 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Choice.js +184 -0
- package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.d.ts +7 -0
- package/dist/fable_modules/fable-library-js.4.28.0/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.d.ts +9 -0
- package/dist/fable_modules/fable-library-js.4.28.0/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Date.d.ts +70 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Date.js +748 -0
- package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.d.ts +63 -0
- package/dist/fable_modules/fable-library-js.4.28.0/DateOffset.js +268 -0
- package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.d.ts +18 -0
- package/dist/fable_modules/fable-library-js.4.28.0/DateOnly.js +124 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Decimal.d.ts +45 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Decimal.js +212 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Double.d.ts +11 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Double.js +46 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Encoding.d.ts +12 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Encoding.js +173 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Event.d.ts +31 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Event.js +93 -0
- package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.d.ts +7 -0
- package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Collections.js +27 -0
- package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.d.ts +12 -0
- package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.CompilerServices.js +27 -0
- package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.d.ts +17 -0
- package/dist/fable_modules/fable-library-js.4.28.0/FSharp.Core.js +69 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Global.d.ts +24 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Global.js +8 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Guid.d.ts +10 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Guid.js +142 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Int32.d.ts +28 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Int32.js +135 -0
- package/dist/fable_modules/fable-library-js.4.28.0/List.d.ts +143 -0
- package/dist/fable_modules/fable-library-js.4.28.0/List.js +1273 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Long.d.ts +3 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Long.js +46 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.d.ts +25 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MailboxProcessor.js +93 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Map.d.ts +178 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Map.js +1396 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.d.ts +12 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MapUtil.js +127 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.d.ts +52 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MutableMap.js +327 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.d.ts +39 -0
- package/dist/fable_modules/fable-library-js.4.28.0/MutableSet.js +233 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Native.d.ts +2 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Native.js +8 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Numeric.d.ts +19 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Numeric.js +71 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Observable.d.ts +32 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Observable.js +113 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Option.d.ts +28 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Option.js +96 -0
- package/dist/fable_modules/fable-library-js.4.28.0/README.md +3 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Random.d.ts +37 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Random.js +170 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Range.d.ts +12 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Range.js +45 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Reflection.d.ts +119 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Reflection.js +461 -0
- package/dist/fable_modules/fable-library-js.4.28.0/RegExp.d.ts +10 -0
- package/dist/fable_modules/fable-library-js.4.28.0/RegExp.js +131 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Result.d.ts +37 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Result.js +165 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Seq.d.ts +165 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Seq.js +1378 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Seq2.d.ts +18 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Seq2.js +111 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Set.d.ts +190 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Set.js +1789 -0
- package/dist/fable_modules/fable-library-js.4.28.0/String.d.ts +58 -0
- package/dist/fable_modules/fable-library-js.4.28.0/String.js +554 -0
- package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.d.ts +79 -0
- package/dist/fable_modules/fable-library-js.4.28.0/System.Collections.Generic.js +317 -0
- package/dist/fable_modules/fable-library-js.4.28.0/System.Text.d.ts +38 -0
- package/dist/fable_modules/fable-library-js.4.28.0/System.Text.js +162 -0
- package/dist/fable_modules/fable-library-js.4.28.0/SystemException.d.ts +5 -0
- package/dist/fable_modules/fable-library-js.4.28.0/SystemException.js +5 -0
- package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.d.ts +15 -0
- package/dist/fable_modules/fable-library-js.4.28.0/TimeOnly.js +122 -0
- package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.d.ts +34 -0
- package/dist/fable_modules/fable-library-js.4.28.0/TimeSpan.js +177 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Timer.d.ts +19 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Timer.js +67 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Types.d.ts +58 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Types.js +208 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.d.ts +2 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Unicode.13.0.0.js +4 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Uri.d.ts +31 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Uri.js +159 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Util.d.ts +210 -0
- package/dist/fable_modules/fable-library-js.4.28.0/Util.js +769 -0
- package/dist/fable_modules/fable-library-js.4.28.0/big.d.ts +338 -0
- package/dist/fable_modules/fable-library-js.4.28.0/lib/big.d.ts +5 -0
- package/dist/fable_modules/fable-library-js.4.28.0/lib/big.js +825 -0
- package/dist/fable_modules/fable-library-js.4.28.0/package.json +24 -0
- package/dist/fable_modules/project_cracked.json +1 -0
- package/package.json +5 -4
- package/.claude/settings.local.json +0 -11
- package/copy-latest.sh +0 -1
- package/dist/fable-library.2.10.1/Array.js +0 -1336
- package/dist/fable-library.2.10.1/Async.js +0 -121
- package/dist/fable-library.2.10.1/AsyncBuilder.js +0 -200
- package/dist/fable-library.2.10.1/Date.js +0 -501
- package/dist/fable-library.2.10.1/Decimal.js +0 -208
- package/dist/fable-library.2.10.1/Event.js +0 -193
- package/dist/fable-library.2.10.1/Int32.js +0 -157
- package/dist/fable-library.2.10.1/List.js +0 -1234
- package/dist/fable-library.2.10.1/Long.js +0 -155
- package/dist/fable-library.2.10.1/Map.js +0 -1292
- package/dist/fable-library.2.10.1/MutableMap.js +0 -360
- package/dist/fable-library.2.10.1/MutableSet.js +0 -279
- package/dist/fable-library.2.10.1/Observable.js +0 -131
- package/dist/fable-library.2.10.1/Option.js +0 -118
- package/dist/fable-library.2.10.1/Reflection.js +0 -345
- package/dist/fable-library.2.10.1/RegExp.js +0 -118
- package/dist/fable-library.2.10.1/Seq.js +0 -917
- package/dist/fable-library.2.10.1/Set.js +0 -1692
- package/dist/fable-library.2.10.1/String.js +0 -679
- package/dist/fable-library.2.10.1/Types.js +0 -308
- package/dist/fable-library.2.10.1/Util.js +0 -761
- package/dist/helpers.js +0 -31
- package/dist/lib/big.js +0 -905
- package/dist/lib/long.js +0 -1375
- package/index.html +0 -49
|
@@ -0,0 +1,1273 @@
|
|
|
1
|
+
import { join } from "./String.js";
|
|
2
|
+
import { defaultArg, some, value as value_1 } from "./Option.js";
|
|
3
|
+
import { disposeSafe, isArrayLike, defaultOf, toIterator, getEnumerator, compare, structuralHash, equals } from "./Util.js";
|
|
4
|
+
import { Record } from "./Types.js";
|
|
5
|
+
import { class_type, record_type, option_type } from "./Reflection.js";
|
|
6
|
+
import { SR_inputSequenceTooLong, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_notEnoughElements, SR_differentLengths, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.js";
|
|
7
|
+
import { 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.js";
|
|
8
|
+
export class FSharpList extends Record {
|
|
9
|
+
constructor(head, tail) {
|
|
10
|
+
super();
|
|
11
|
+
this.head = head;
|
|
12
|
+
this.tail = tail;
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
const xs = this;
|
|
16
|
+
return ("[" + join("; ", xs)) + "]";
|
|
17
|
+
}
|
|
18
|
+
Equals(other) {
|
|
19
|
+
const xs = this;
|
|
20
|
+
if (xs === other) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const loop = (xs_1_mut, ys_1_mut) => {
|
|
25
|
+
loop: while (true) {
|
|
26
|
+
const xs_1 = xs_1_mut, ys_1 = ys_1_mut;
|
|
27
|
+
const matchValue = xs_1.tail;
|
|
28
|
+
const matchValue_1 = ys_1.tail;
|
|
29
|
+
if (matchValue != null) {
|
|
30
|
+
if (matchValue_1 != null) {
|
|
31
|
+
const xt = value_1(matchValue);
|
|
32
|
+
const yt = value_1(matchValue_1);
|
|
33
|
+
if (equals(xs_1.head, ys_1.head)) {
|
|
34
|
+
xs_1_mut = xt;
|
|
35
|
+
ys_1_mut = yt;
|
|
36
|
+
continue loop;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (matchValue_1 != null) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return loop(xs, other);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
GetHashCode() {
|
|
59
|
+
const xs = this;
|
|
60
|
+
const loop = (i_mut, h_mut, xs_1_mut) => {
|
|
61
|
+
loop: while (true) {
|
|
62
|
+
const i = i_mut, h = h_mut, xs_1 = xs_1_mut;
|
|
63
|
+
const matchValue = xs_1.tail;
|
|
64
|
+
if (matchValue != null) {
|
|
65
|
+
const t = value_1(matchValue);
|
|
66
|
+
if (i > 18) {
|
|
67
|
+
return h | 0;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
i_mut = (i + 1);
|
|
71
|
+
h_mut = (((h << 1) + structuralHash(xs_1.head)) + (631 * i));
|
|
72
|
+
xs_1_mut = t;
|
|
73
|
+
continue loop;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return h | 0;
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return loop(0, 0, xs) | 0;
|
|
83
|
+
}
|
|
84
|
+
toJSON() {
|
|
85
|
+
const this$ = this;
|
|
86
|
+
return Array.from(this$);
|
|
87
|
+
}
|
|
88
|
+
CompareTo(other) {
|
|
89
|
+
const xs = this;
|
|
90
|
+
const loop = (xs_1_mut, ys_1_mut) => {
|
|
91
|
+
loop: while (true) {
|
|
92
|
+
const xs_1 = xs_1_mut, ys_1 = ys_1_mut;
|
|
93
|
+
const matchValue = xs_1.tail;
|
|
94
|
+
const matchValue_1 = ys_1.tail;
|
|
95
|
+
if (matchValue != null) {
|
|
96
|
+
if (matchValue_1 != null) {
|
|
97
|
+
const xt = value_1(matchValue);
|
|
98
|
+
const yt = value_1(matchValue_1);
|
|
99
|
+
const c = compare(xs_1.head, ys_1.head) | 0;
|
|
100
|
+
if (c === 0) {
|
|
101
|
+
xs_1_mut = xt;
|
|
102
|
+
ys_1_mut = yt;
|
|
103
|
+
continue loop;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return c | 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (matchValue_1 != null) {
|
|
114
|
+
return -1;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
return loop(xs, other) | 0;
|
|
123
|
+
}
|
|
124
|
+
GetEnumerator() {
|
|
125
|
+
const xs = this;
|
|
126
|
+
return ListEnumerator$1_$ctor_3002E699(xs);
|
|
127
|
+
}
|
|
128
|
+
[Symbol.iterator]() {
|
|
129
|
+
return toIterator(getEnumerator(this));
|
|
130
|
+
}
|
|
131
|
+
"System.Collections.IEnumerable.GetEnumerator"() {
|
|
132
|
+
const xs = this;
|
|
133
|
+
return getEnumerator(xs);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function FSharpList_$reflection(gen0) {
|
|
137
|
+
return record_type("ListModule.FSharpList", [gen0], FSharpList, () => [["head", gen0], ["tail", option_type(FSharpList_$reflection(gen0))]]);
|
|
138
|
+
}
|
|
139
|
+
export class ListEnumerator$1 {
|
|
140
|
+
constructor(xs) {
|
|
141
|
+
this.xs = xs;
|
|
142
|
+
this.it = this.xs;
|
|
143
|
+
this.current = defaultOf();
|
|
144
|
+
}
|
|
145
|
+
"System.Collections.Generic.IEnumerator`1.get_Current"() {
|
|
146
|
+
const _ = this;
|
|
147
|
+
return _.current;
|
|
148
|
+
}
|
|
149
|
+
"System.Collections.IEnumerator.get_Current"() {
|
|
150
|
+
const _ = this;
|
|
151
|
+
return _.current;
|
|
152
|
+
}
|
|
153
|
+
"System.Collections.IEnumerator.MoveNext"() {
|
|
154
|
+
const _ = this;
|
|
155
|
+
const matchValue = _.it.tail;
|
|
156
|
+
if (matchValue != null) {
|
|
157
|
+
const t = value_1(matchValue);
|
|
158
|
+
_.current = _.it.head;
|
|
159
|
+
_.it = t;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
"System.Collections.IEnumerator.Reset"() {
|
|
167
|
+
const _ = this;
|
|
168
|
+
_.it = _.xs;
|
|
169
|
+
_.current = defaultOf();
|
|
170
|
+
}
|
|
171
|
+
Dispose() {
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
export function ListEnumerator$1_$reflection(gen0) {
|
|
175
|
+
return class_type("ListModule.ListEnumerator`1", [gen0], ListEnumerator$1);
|
|
176
|
+
}
|
|
177
|
+
export function ListEnumerator$1_$ctor_3002E699(xs) {
|
|
178
|
+
return new ListEnumerator$1(xs);
|
|
179
|
+
}
|
|
180
|
+
export function FSharpList_get_Empty() {
|
|
181
|
+
return new FSharpList(defaultOf(), undefined);
|
|
182
|
+
}
|
|
183
|
+
export function FSharpList_Cons_305B8EAC(x, xs) {
|
|
184
|
+
return new FSharpList(x, xs);
|
|
185
|
+
}
|
|
186
|
+
export function FSharpList__get_IsEmpty(xs) {
|
|
187
|
+
return xs.tail == null;
|
|
188
|
+
}
|
|
189
|
+
export function FSharpList__get_Length(xs) {
|
|
190
|
+
const loop = (i_mut, xs_1_mut) => {
|
|
191
|
+
loop: while (true) {
|
|
192
|
+
const i = i_mut, xs_1 = xs_1_mut;
|
|
193
|
+
const matchValue = xs_1.tail;
|
|
194
|
+
if (matchValue != null) {
|
|
195
|
+
i_mut = (i + 1);
|
|
196
|
+
xs_1_mut = value_1(matchValue);
|
|
197
|
+
continue loop;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
return i | 0;
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return loop(0, xs) | 0;
|
|
206
|
+
}
|
|
207
|
+
export function FSharpList__get_Head(xs) {
|
|
208
|
+
const matchValue = xs.tail;
|
|
209
|
+
if (matchValue != null) {
|
|
210
|
+
return xs.head;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
throw new Error((SR_inputWasEmpty + "\\nParameter name: ") + "list");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export function FSharpList__get_Tail(xs) {
|
|
217
|
+
const matchValue = xs.tail;
|
|
218
|
+
if (matchValue != null) {
|
|
219
|
+
return value_1(matchValue);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
throw new Error((SR_inputWasEmpty + "\\nParameter name: ") + "list");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export function FSharpList__get_Item_Z524259A4(xs, index) {
|
|
226
|
+
const loop = (i_mut, xs_1_mut) => {
|
|
227
|
+
loop: while (true) {
|
|
228
|
+
const i = i_mut, xs_1 = xs_1_mut;
|
|
229
|
+
const matchValue = xs_1.tail;
|
|
230
|
+
if (matchValue != null) {
|
|
231
|
+
if (i === index) {
|
|
232
|
+
return xs_1.head;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
i_mut = (i + 1);
|
|
236
|
+
xs_1_mut = value_1(matchValue);
|
|
237
|
+
continue loop;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
return loop(0, xs);
|
|
247
|
+
}
|
|
248
|
+
export function indexNotFound() {
|
|
249
|
+
throw new Error(SR_keyNotFoundAlt);
|
|
250
|
+
}
|
|
251
|
+
export function empty() {
|
|
252
|
+
return FSharpList_get_Empty();
|
|
253
|
+
}
|
|
254
|
+
export function cons(x, xs) {
|
|
255
|
+
return FSharpList_Cons_305B8EAC(x, xs);
|
|
256
|
+
}
|
|
257
|
+
export function singleton(x) {
|
|
258
|
+
return FSharpList_Cons_305B8EAC(x, FSharpList_get_Empty());
|
|
259
|
+
}
|
|
260
|
+
export function isEmpty(xs) {
|
|
261
|
+
return FSharpList__get_IsEmpty(xs);
|
|
262
|
+
}
|
|
263
|
+
export function length(xs) {
|
|
264
|
+
return FSharpList__get_Length(xs);
|
|
265
|
+
}
|
|
266
|
+
export function head(xs) {
|
|
267
|
+
return FSharpList__get_Head(xs);
|
|
268
|
+
}
|
|
269
|
+
export function tryHead(xs) {
|
|
270
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return some(FSharpList__get_Head(xs));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export function tail(xs) {
|
|
278
|
+
return FSharpList__get_Tail(xs);
|
|
279
|
+
}
|
|
280
|
+
export function tryLast(xs_mut) {
|
|
281
|
+
tryLast: while (true) {
|
|
282
|
+
const xs = xs_mut;
|
|
283
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const t = FSharpList__get_Tail(xs);
|
|
288
|
+
if (FSharpList__get_IsEmpty(t)) {
|
|
289
|
+
return some(FSharpList__get_Head(xs));
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
xs_mut = t;
|
|
293
|
+
continue tryLast;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
export function last(xs) {
|
|
300
|
+
const matchValue = tryLast(xs);
|
|
301
|
+
if (matchValue == null) {
|
|
302
|
+
throw new Error(SR_inputWasEmpty);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
return value_1(matchValue);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
export function compareWith(comparer, xs, ys) {
|
|
309
|
+
const loop = (xs_1_mut, ys_1_mut) => {
|
|
310
|
+
loop: while (true) {
|
|
311
|
+
const xs_1 = xs_1_mut, ys_1 = ys_1_mut;
|
|
312
|
+
const matchValue = FSharpList__get_IsEmpty(xs_1);
|
|
313
|
+
const matchValue_1 = FSharpList__get_IsEmpty(ys_1);
|
|
314
|
+
if (matchValue) {
|
|
315
|
+
if (matchValue_1) {
|
|
316
|
+
return 0;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
return -1;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (matchValue_1) {
|
|
323
|
+
return 1;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
const c = comparer(FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1)) | 0;
|
|
327
|
+
if (c === 0) {
|
|
328
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
329
|
+
ys_1_mut = FSharpList__get_Tail(ys_1);
|
|
330
|
+
continue loop;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
return c | 0;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
return loop(xs, ys) | 0;
|
|
340
|
+
}
|
|
341
|
+
export function toArray(xs) {
|
|
342
|
+
const len = FSharpList__get_Length(xs) | 0;
|
|
343
|
+
const res = fill(new Array(len), 0, len, null);
|
|
344
|
+
const loop = (i_mut, xs_1_mut) => {
|
|
345
|
+
loop: while (true) {
|
|
346
|
+
const i = i_mut, xs_1 = xs_1_mut;
|
|
347
|
+
if (!FSharpList__get_IsEmpty(xs_1)) {
|
|
348
|
+
setItem(res, i, FSharpList__get_Head(xs_1));
|
|
349
|
+
i_mut = (i + 1);
|
|
350
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
351
|
+
continue loop;
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
loop(0, xs);
|
|
357
|
+
return res;
|
|
358
|
+
}
|
|
359
|
+
export function fold(folder, state, xs) {
|
|
360
|
+
let acc = state;
|
|
361
|
+
let xs_1 = xs;
|
|
362
|
+
while (!FSharpList__get_IsEmpty(xs_1)) {
|
|
363
|
+
acc = folder(acc, head(xs_1));
|
|
364
|
+
xs_1 = FSharpList__get_Tail(xs_1);
|
|
365
|
+
}
|
|
366
|
+
return acc;
|
|
367
|
+
}
|
|
368
|
+
export function reverse(xs) {
|
|
369
|
+
return fold((acc, x) => FSharpList_Cons_305B8EAC(x, acc), FSharpList_get_Empty(), xs);
|
|
370
|
+
}
|
|
371
|
+
export function foldBack(folder, xs, state) {
|
|
372
|
+
return foldBack_1(folder, toArray(xs), state);
|
|
373
|
+
}
|
|
374
|
+
export function foldIndexed(folder, state, xs) {
|
|
375
|
+
const loop = (i_mut, acc_mut, xs_1_mut) => {
|
|
376
|
+
loop: while (true) {
|
|
377
|
+
const i = i_mut, acc = acc_mut, xs_1 = xs_1_mut;
|
|
378
|
+
if (FSharpList__get_IsEmpty(xs_1)) {
|
|
379
|
+
return acc;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
i_mut = (i + 1);
|
|
383
|
+
acc_mut = folder(i, acc, FSharpList__get_Head(xs_1));
|
|
384
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
385
|
+
continue loop;
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
return loop(0, state, xs);
|
|
391
|
+
}
|
|
392
|
+
export function fold2(folder, state, xs, ys) {
|
|
393
|
+
let acc = state;
|
|
394
|
+
let xs_1 = xs;
|
|
395
|
+
let ys_1 = ys;
|
|
396
|
+
while (!FSharpList__get_IsEmpty(xs_1) && !FSharpList__get_IsEmpty(ys_1)) {
|
|
397
|
+
acc = folder(acc, FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1));
|
|
398
|
+
xs_1 = FSharpList__get_Tail(xs_1);
|
|
399
|
+
ys_1 = FSharpList__get_Tail(ys_1);
|
|
400
|
+
}
|
|
401
|
+
return acc;
|
|
402
|
+
}
|
|
403
|
+
export function foldBack2(folder, xs, ys, state) {
|
|
404
|
+
return foldBack2_1(folder, toArray(xs), toArray(ys), state);
|
|
405
|
+
}
|
|
406
|
+
export function unfold(gen, state) {
|
|
407
|
+
const loop = (acc_mut, node_mut) => {
|
|
408
|
+
let t;
|
|
409
|
+
loop: while (true) {
|
|
410
|
+
const acc = acc_mut, node = node_mut;
|
|
411
|
+
const matchValue = gen(acc);
|
|
412
|
+
if (matchValue != null) {
|
|
413
|
+
acc_mut = value_1(matchValue)[1];
|
|
414
|
+
node_mut = ((t = (new FSharpList(value_1(matchValue)[0], undefined)), (node.tail = t, t)));
|
|
415
|
+
continue loop;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
return node;
|
|
419
|
+
}
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
const root = FSharpList_get_Empty();
|
|
424
|
+
const node_1 = loop(state, root);
|
|
425
|
+
const t_2 = FSharpList_get_Empty();
|
|
426
|
+
node_1.tail = t_2;
|
|
427
|
+
return FSharpList__get_Tail(root);
|
|
428
|
+
}
|
|
429
|
+
export function iterate(action, xs) {
|
|
430
|
+
fold((unitVar, x) => {
|
|
431
|
+
action(x);
|
|
432
|
+
}, undefined, xs);
|
|
433
|
+
}
|
|
434
|
+
export function iterate2(action, xs, ys) {
|
|
435
|
+
fold2((unitVar, x, y) => {
|
|
436
|
+
action(x, y);
|
|
437
|
+
}, undefined, xs, ys);
|
|
438
|
+
}
|
|
439
|
+
export function iterateIndexed(action, xs) {
|
|
440
|
+
fold((i, x) => {
|
|
441
|
+
action(i, x);
|
|
442
|
+
return (i + 1) | 0;
|
|
443
|
+
}, 0, xs);
|
|
444
|
+
}
|
|
445
|
+
export function iterateIndexed2(action, xs, ys) {
|
|
446
|
+
fold2((i, x, y) => {
|
|
447
|
+
action(i, x, y);
|
|
448
|
+
return (i + 1) | 0;
|
|
449
|
+
}, 0, xs, ys);
|
|
450
|
+
}
|
|
451
|
+
export function toSeq(xs) {
|
|
452
|
+
return xs;
|
|
453
|
+
}
|
|
454
|
+
export function ofArrayWithTail(xs, tail_1) {
|
|
455
|
+
let res = tail_1;
|
|
456
|
+
for (let i = xs.length - 1; i >= 0; i--) {
|
|
457
|
+
res = FSharpList_Cons_305B8EAC(item_1(i, xs), res);
|
|
458
|
+
}
|
|
459
|
+
return res;
|
|
460
|
+
}
|
|
461
|
+
export function ofArray(xs) {
|
|
462
|
+
return ofArrayWithTail(xs, FSharpList_get_Empty());
|
|
463
|
+
}
|
|
464
|
+
export function ofSeq(xs) {
|
|
465
|
+
let xs_3, t;
|
|
466
|
+
if (isArrayLike(xs)) {
|
|
467
|
+
return ofArray(xs);
|
|
468
|
+
}
|
|
469
|
+
else if (xs instanceof FSharpList) {
|
|
470
|
+
return xs;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
const root = FSharpList_get_Empty();
|
|
474
|
+
let node = root;
|
|
475
|
+
const enumerator = getEnumerator(xs);
|
|
476
|
+
try {
|
|
477
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
478
|
+
const x = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
479
|
+
node = ((xs_3 = node, (t = (new FSharpList(x, undefined)), (xs_3.tail = t, t))));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
finally {
|
|
483
|
+
disposeSafe(enumerator);
|
|
484
|
+
}
|
|
485
|
+
const xs_5 = node;
|
|
486
|
+
const t_2 = FSharpList_get_Empty();
|
|
487
|
+
xs_5.tail = t_2;
|
|
488
|
+
return FSharpList__get_Tail(root);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
export function concat(lists) {
|
|
492
|
+
const root = FSharpList_get_Empty();
|
|
493
|
+
let node = root;
|
|
494
|
+
const action = (xs) => {
|
|
495
|
+
node = fold((acc, x) => {
|
|
496
|
+
const t = new FSharpList(x, undefined);
|
|
497
|
+
acc.tail = t;
|
|
498
|
+
return t;
|
|
499
|
+
}, node, xs);
|
|
500
|
+
};
|
|
501
|
+
if (isArrayLike(lists)) {
|
|
502
|
+
const xs_3 = lists;
|
|
503
|
+
xs_3.forEach(action);
|
|
504
|
+
}
|
|
505
|
+
else if (lists instanceof FSharpList) {
|
|
506
|
+
iterate(action, lists);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
const enumerator = getEnumerator(lists);
|
|
510
|
+
try {
|
|
511
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
512
|
+
action(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
finally {
|
|
516
|
+
disposeSafe(enumerator);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const xs_6 = node;
|
|
520
|
+
const t_2 = FSharpList_get_Empty();
|
|
521
|
+
xs_6.tail = t_2;
|
|
522
|
+
return FSharpList__get_Tail(root);
|
|
523
|
+
}
|
|
524
|
+
export function scan(folder, state, xs) {
|
|
525
|
+
let xs_4, t_2;
|
|
526
|
+
const root = FSharpList_get_Empty();
|
|
527
|
+
let node;
|
|
528
|
+
const t = new FSharpList(state, undefined);
|
|
529
|
+
root.tail = t;
|
|
530
|
+
node = t;
|
|
531
|
+
let acc = state;
|
|
532
|
+
let xs_3 = xs;
|
|
533
|
+
while (!FSharpList__get_IsEmpty(xs_3)) {
|
|
534
|
+
acc = folder(acc, FSharpList__get_Head(xs_3));
|
|
535
|
+
node = ((xs_4 = node, (t_2 = (new FSharpList(acc, undefined)), (xs_4.tail = t_2, t_2))));
|
|
536
|
+
xs_3 = FSharpList__get_Tail(xs_3);
|
|
537
|
+
}
|
|
538
|
+
const xs_6 = node;
|
|
539
|
+
const t_4 = FSharpList_get_Empty();
|
|
540
|
+
xs_6.tail = t_4;
|
|
541
|
+
return FSharpList__get_Tail(root);
|
|
542
|
+
}
|
|
543
|
+
export function scanBack(folder, xs, state) {
|
|
544
|
+
return ofArray(scanBack_1(folder, toArray(xs), state));
|
|
545
|
+
}
|
|
546
|
+
export function append(xs, ys) {
|
|
547
|
+
return fold((acc, x) => FSharpList_Cons_305B8EAC(x, acc), ys, reverse(xs));
|
|
548
|
+
}
|
|
549
|
+
export function collect(mapping, xs) {
|
|
550
|
+
let xs_1, t;
|
|
551
|
+
const root = FSharpList_get_Empty();
|
|
552
|
+
let node = root;
|
|
553
|
+
let ys = xs;
|
|
554
|
+
while (!FSharpList__get_IsEmpty(ys)) {
|
|
555
|
+
let zs = mapping(FSharpList__get_Head(ys));
|
|
556
|
+
while (!FSharpList__get_IsEmpty(zs)) {
|
|
557
|
+
node = ((xs_1 = node, (t = (new FSharpList(FSharpList__get_Head(zs), undefined)), (xs_1.tail = t, t))));
|
|
558
|
+
zs = FSharpList__get_Tail(zs);
|
|
559
|
+
}
|
|
560
|
+
ys = FSharpList__get_Tail(ys);
|
|
561
|
+
}
|
|
562
|
+
const xs_3 = node;
|
|
563
|
+
const t_2 = FSharpList_get_Empty();
|
|
564
|
+
xs_3.tail = t_2;
|
|
565
|
+
return FSharpList__get_Tail(root);
|
|
566
|
+
}
|
|
567
|
+
export function mapIndexed(mapping, xs) {
|
|
568
|
+
const root = FSharpList_get_Empty();
|
|
569
|
+
const node = foldIndexed((i, acc, x) => {
|
|
570
|
+
const t = new FSharpList(mapping(i, x), undefined);
|
|
571
|
+
acc.tail = t;
|
|
572
|
+
return t;
|
|
573
|
+
}, root, xs);
|
|
574
|
+
const t_2 = FSharpList_get_Empty();
|
|
575
|
+
node.tail = t_2;
|
|
576
|
+
return FSharpList__get_Tail(root);
|
|
577
|
+
}
|
|
578
|
+
export function map(mapping, xs) {
|
|
579
|
+
const root = FSharpList_get_Empty();
|
|
580
|
+
const node = fold((acc, x) => {
|
|
581
|
+
const t = new FSharpList(mapping(x), undefined);
|
|
582
|
+
acc.tail = t;
|
|
583
|
+
return t;
|
|
584
|
+
}, root, xs);
|
|
585
|
+
const t_2 = FSharpList_get_Empty();
|
|
586
|
+
node.tail = t_2;
|
|
587
|
+
return FSharpList__get_Tail(root);
|
|
588
|
+
}
|
|
589
|
+
export function indexed(xs) {
|
|
590
|
+
return mapIndexed((i, x) => [i, x], xs);
|
|
591
|
+
}
|
|
592
|
+
export function map2(mapping, xs, ys) {
|
|
593
|
+
const root = FSharpList_get_Empty();
|
|
594
|
+
const node = fold2((acc, x, y) => {
|
|
595
|
+
const t = new FSharpList(mapping(x, y), undefined);
|
|
596
|
+
acc.tail = t;
|
|
597
|
+
return t;
|
|
598
|
+
}, root, xs, ys);
|
|
599
|
+
const t_2 = FSharpList_get_Empty();
|
|
600
|
+
node.tail = t_2;
|
|
601
|
+
return FSharpList__get_Tail(root);
|
|
602
|
+
}
|
|
603
|
+
export function mapIndexed2(mapping, xs, ys) {
|
|
604
|
+
const loop = (i_mut, acc_mut, xs_1_mut, ys_1_mut) => {
|
|
605
|
+
let t;
|
|
606
|
+
loop: while (true) {
|
|
607
|
+
const i = i_mut, acc = acc_mut, xs_1 = xs_1_mut, ys_1 = ys_1_mut;
|
|
608
|
+
if (FSharpList__get_IsEmpty(xs_1) ? true : FSharpList__get_IsEmpty(ys_1)) {
|
|
609
|
+
return acc;
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
i_mut = (i + 1);
|
|
613
|
+
acc_mut = ((t = (new FSharpList(mapping(i, FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1)), undefined)), (acc.tail = t, t)));
|
|
614
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
615
|
+
ys_1_mut = FSharpList__get_Tail(ys_1);
|
|
616
|
+
continue loop;
|
|
617
|
+
}
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
const root = FSharpList_get_Empty();
|
|
622
|
+
const node_1 = loop(0, root, xs, ys);
|
|
623
|
+
const t_2 = FSharpList_get_Empty();
|
|
624
|
+
node_1.tail = t_2;
|
|
625
|
+
return FSharpList__get_Tail(root);
|
|
626
|
+
}
|
|
627
|
+
export function map3(mapping, xs, ys, zs) {
|
|
628
|
+
const loop = (acc_mut, xs_1_mut, ys_1_mut, zs_1_mut) => {
|
|
629
|
+
let t;
|
|
630
|
+
loop: while (true) {
|
|
631
|
+
const acc = acc_mut, xs_1 = xs_1_mut, ys_1 = ys_1_mut, zs_1 = zs_1_mut;
|
|
632
|
+
if ((FSharpList__get_IsEmpty(xs_1) ? true : FSharpList__get_IsEmpty(ys_1)) ? true : FSharpList__get_IsEmpty(zs_1)) {
|
|
633
|
+
return acc;
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
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)));
|
|
637
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
638
|
+
ys_1_mut = FSharpList__get_Tail(ys_1);
|
|
639
|
+
zs_1_mut = FSharpList__get_Tail(zs_1);
|
|
640
|
+
continue loop;
|
|
641
|
+
}
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
const root = FSharpList_get_Empty();
|
|
646
|
+
const node_1 = loop(root, xs, ys, zs);
|
|
647
|
+
const t_2 = FSharpList_get_Empty();
|
|
648
|
+
node_1.tail = t_2;
|
|
649
|
+
return FSharpList__get_Tail(root);
|
|
650
|
+
}
|
|
651
|
+
export function mapFold(mapping, state, xs) {
|
|
652
|
+
const root = FSharpList_get_Empty();
|
|
653
|
+
const patternInput_1 = fold((tupledArg, x) => {
|
|
654
|
+
let t;
|
|
655
|
+
const patternInput = mapping(tupledArg[1], x);
|
|
656
|
+
return [(t = (new FSharpList(patternInput[0], undefined)), (tupledArg[0].tail = t, t)), patternInput[1]];
|
|
657
|
+
}, [root, state], xs);
|
|
658
|
+
const t_2 = FSharpList_get_Empty();
|
|
659
|
+
patternInput_1[0].tail = t_2;
|
|
660
|
+
return [FSharpList__get_Tail(root), patternInput_1[1]];
|
|
661
|
+
}
|
|
662
|
+
export function mapFoldBack(mapping, xs, state) {
|
|
663
|
+
return mapFold((acc, x) => mapping(x, acc), state, reverse(xs));
|
|
664
|
+
}
|
|
665
|
+
export function tryPick(f, xs) {
|
|
666
|
+
const loop = (xs_1_mut) => {
|
|
667
|
+
loop: while (true) {
|
|
668
|
+
const xs_1 = xs_1_mut;
|
|
669
|
+
if (FSharpList__get_IsEmpty(xs_1)) {
|
|
670
|
+
return undefined;
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
const matchValue = f(FSharpList__get_Head(xs_1));
|
|
674
|
+
if (matchValue == null) {
|
|
675
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
676
|
+
continue loop;
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
return matchValue;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
return loop(xs);
|
|
686
|
+
}
|
|
687
|
+
export function pick(f, xs) {
|
|
688
|
+
const matchValue = tryPick(f, xs);
|
|
689
|
+
if (matchValue == null) {
|
|
690
|
+
return indexNotFound();
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
return value_1(matchValue);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
export function tryFind(f, xs) {
|
|
697
|
+
return tryPick((x) => (f(x) ? some(x) : undefined), xs);
|
|
698
|
+
}
|
|
699
|
+
export function find(f, xs) {
|
|
700
|
+
const matchValue = tryFind(f, xs);
|
|
701
|
+
if (matchValue == null) {
|
|
702
|
+
return indexNotFound();
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
return value_1(matchValue);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
export function tryFindBack(f, xs) {
|
|
709
|
+
return tryFindBack_1(f, toArray(xs));
|
|
710
|
+
}
|
|
711
|
+
export function findBack(f, xs) {
|
|
712
|
+
const matchValue = tryFindBack(f, xs);
|
|
713
|
+
if (matchValue == null) {
|
|
714
|
+
return indexNotFound();
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
return value_1(matchValue);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
export function tryFindIndex(f, xs) {
|
|
721
|
+
const loop = (i_mut, xs_1_mut) => {
|
|
722
|
+
loop: while (true) {
|
|
723
|
+
const i = i_mut, xs_1 = xs_1_mut;
|
|
724
|
+
if (FSharpList__get_IsEmpty(xs_1)) {
|
|
725
|
+
return undefined;
|
|
726
|
+
}
|
|
727
|
+
else if (f(FSharpList__get_Head(xs_1))) {
|
|
728
|
+
return i;
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
i_mut = (i + 1);
|
|
732
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
733
|
+
continue loop;
|
|
734
|
+
}
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
return loop(0, xs);
|
|
739
|
+
}
|
|
740
|
+
export function findIndex(f, xs) {
|
|
741
|
+
const matchValue = tryFindIndex(f, xs);
|
|
742
|
+
if (matchValue == null) {
|
|
743
|
+
indexNotFound();
|
|
744
|
+
return -1;
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
return value_1(matchValue) | 0;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
export function tryFindIndexBack(f, xs) {
|
|
751
|
+
return tryFindIndexBack_1(f, toArray(xs));
|
|
752
|
+
}
|
|
753
|
+
export function findIndexBack(f, xs) {
|
|
754
|
+
const matchValue = tryFindIndexBack(f, xs);
|
|
755
|
+
if (matchValue == null) {
|
|
756
|
+
indexNotFound();
|
|
757
|
+
return -1;
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
return value_1(matchValue) | 0;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
export function tryItem(n, xs) {
|
|
764
|
+
const loop = (i_mut, xs_1_mut) => {
|
|
765
|
+
loop: while (true) {
|
|
766
|
+
const i = i_mut, xs_1 = xs_1_mut;
|
|
767
|
+
if (FSharpList__get_IsEmpty(xs_1)) {
|
|
768
|
+
return undefined;
|
|
769
|
+
}
|
|
770
|
+
else if (i === n) {
|
|
771
|
+
return some(FSharpList__get_Head(xs_1));
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
i_mut = (i + 1);
|
|
775
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
776
|
+
continue loop;
|
|
777
|
+
}
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
return loop(0, xs);
|
|
782
|
+
}
|
|
783
|
+
export function item(n, xs) {
|
|
784
|
+
return FSharpList__get_Item_Z524259A4(xs, n);
|
|
785
|
+
}
|
|
786
|
+
export function filter(f, xs) {
|
|
787
|
+
const root = FSharpList_get_Empty();
|
|
788
|
+
const node = fold((acc, x) => {
|
|
789
|
+
if (f(x)) {
|
|
790
|
+
const t = new FSharpList(x, undefined);
|
|
791
|
+
acc.tail = t;
|
|
792
|
+
return t;
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
return acc;
|
|
796
|
+
}
|
|
797
|
+
}, root, xs);
|
|
798
|
+
const t_2 = FSharpList_get_Empty();
|
|
799
|
+
node.tail = t_2;
|
|
800
|
+
return FSharpList__get_Tail(root);
|
|
801
|
+
}
|
|
802
|
+
export function partition(f, xs) {
|
|
803
|
+
const matchValue = FSharpList_get_Empty();
|
|
804
|
+
const root2 = FSharpList_get_Empty();
|
|
805
|
+
const root1 = matchValue;
|
|
806
|
+
const patternInput_1 = fold((tupledArg, x) => {
|
|
807
|
+
let t, t_2;
|
|
808
|
+
const lacc = tupledArg[0];
|
|
809
|
+
const racc = tupledArg[1];
|
|
810
|
+
if (f(x)) {
|
|
811
|
+
return [(t = (new FSharpList(x, undefined)), (lacc.tail = t, t)), racc];
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
return [lacc, (t_2 = (new FSharpList(x, undefined)), (racc.tail = t_2, t_2))];
|
|
815
|
+
}
|
|
816
|
+
}, [root1, root2], xs);
|
|
817
|
+
const t_4 = FSharpList_get_Empty();
|
|
818
|
+
patternInput_1[0].tail = t_4;
|
|
819
|
+
const t_5 = FSharpList_get_Empty();
|
|
820
|
+
patternInput_1[1].tail = t_5;
|
|
821
|
+
return [FSharpList__get_Tail(root1), FSharpList__get_Tail(root2)];
|
|
822
|
+
}
|
|
823
|
+
export function choose(f, xs) {
|
|
824
|
+
const root = FSharpList_get_Empty();
|
|
825
|
+
const node = fold((acc, x) => {
|
|
826
|
+
const matchValue = f(x);
|
|
827
|
+
if (matchValue == null) {
|
|
828
|
+
return acc;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
const t = new FSharpList(value_1(matchValue), undefined);
|
|
832
|
+
acc.tail = t;
|
|
833
|
+
return t;
|
|
834
|
+
}
|
|
835
|
+
}, root, xs);
|
|
836
|
+
const t_2 = FSharpList_get_Empty();
|
|
837
|
+
node.tail = t_2;
|
|
838
|
+
return FSharpList__get_Tail(root);
|
|
839
|
+
}
|
|
840
|
+
export function contains(value, xs, eq) {
|
|
841
|
+
return tryFindIndex((v) => eq.Equals(value, v), xs) != null;
|
|
842
|
+
}
|
|
843
|
+
export function initialize(n, f) {
|
|
844
|
+
let xs, t;
|
|
845
|
+
const root = FSharpList_get_Empty();
|
|
846
|
+
let node = root;
|
|
847
|
+
for (let i = 0; i <= (n - 1); i++) {
|
|
848
|
+
node = ((xs = node, (t = (new FSharpList(f(i), undefined)), (xs.tail = t, t))));
|
|
849
|
+
}
|
|
850
|
+
const xs_2 = node;
|
|
851
|
+
const t_2 = FSharpList_get_Empty();
|
|
852
|
+
xs_2.tail = t_2;
|
|
853
|
+
return FSharpList__get_Tail(root);
|
|
854
|
+
}
|
|
855
|
+
export function replicate(n, x) {
|
|
856
|
+
return initialize(n, (_arg) => x);
|
|
857
|
+
}
|
|
858
|
+
export function reduce(f, xs) {
|
|
859
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
860
|
+
throw new Error(SR_inputWasEmpty);
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
return fold(f, head(xs), tail(xs));
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
export function reduceBack(f, xs) {
|
|
867
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
868
|
+
throw new Error(SR_inputWasEmpty);
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
return foldBack(f, tail(xs), head(xs));
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
export function forAll(f, xs) {
|
|
875
|
+
return fold((acc, x) => (acc && f(x)), true, xs);
|
|
876
|
+
}
|
|
877
|
+
export function forAll2(f, xs, ys) {
|
|
878
|
+
return fold2((acc, x, y) => (acc && f(x, y)), true, xs, ys);
|
|
879
|
+
}
|
|
880
|
+
export function exists(f, xs) {
|
|
881
|
+
return tryFindIndex(f, xs) != null;
|
|
882
|
+
}
|
|
883
|
+
export function exists2(f_mut, xs_mut, ys_mut) {
|
|
884
|
+
exists2: while (true) {
|
|
885
|
+
const f = f_mut, xs = xs_mut, ys = ys_mut;
|
|
886
|
+
const matchValue = FSharpList__get_IsEmpty(xs);
|
|
887
|
+
const matchValue_1 = FSharpList__get_IsEmpty(ys);
|
|
888
|
+
let matchResult;
|
|
889
|
+
if (matchValue) {
|
|
890
|
+
if (matchValue_1) {
|
|
891
|
+
matchResult = 0;
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
matchResult = 2;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
else if (matchValue_1) {
|
|
898
|
+
matchResult = 2;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
matchResult = 1;
|
|
902
|
+
}
|
|
903
|
+
switch (matchResult) {
|
|
904
|
+
case 0:
|
|
905
|
+
return false;
|
|
906
|
+
case 1:
|
|
907
|
+
if (f(FSharpList__get_Head(xs), FSharpList__get_Head(ys))) {
|
|
908
|
+
return true;
|
|
909
|
+
}
|
|
910
|
+
else {
|
|
911
|
+
f_mut = f;
|
|
912
|
+
xs_mut = FSharpList__get_Tail(xs);
|
|
913
|
+
ys_mut = FSharpList__get_Tail(ys);
|
|
914
|
+
continue exists2;
|
|
915
|
+
}
|
|
916
|
+
default:
|
|
917
|
+
throw new Error((SR_differentLengths + "\\nParameter name: ") + "list2");
|
|
918
|
+
}
|
|
919
|
+
break;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
export function unzip(xs) {
|
|
923
|
+
return foldBack((tupledArg, tupledArg_1) => [FSharpList_Cons_305B8EAC(tupledArg[0], tupledArg_1[0]), FSharpList_Cons_305B8EAC(tupledArg[1], tupledArg_1[1])], xs, [FSharpList_get_Empty(), FSharpList_get_Empty()]);
|
|
924
|
+
}
|
|
925
|
+
export function unzip3(xs) {
|
|
926
|
+
return foldBack((tupledArg, tupledArg_1) => [FSharpList_Cons_305B8EAC(tupledArg[0], tupledArg_1[0]), FSharpList_Cons_305B8EAC(tupledArg[1], tupledArg_1[1]), FSharpList_Cons_305B8EAC(tupledArg[2], tupledArg_1[2])], xs, [FSharpList_get_Empty(), FSharpList_get_Empty(), FSharpList_get_Empty()]);
|
|
927
|
+
}
|
|
928
|
+
export function zip(xs, ys) {
|
|
929
|
+
return map2((x, y) => [x, y], xs, ys);
|
|
930
|
+
}
|
|
931
|
+
export function zip3(xs, ys, zs) {
|
|
932
|
+
return map3((x, y, z) => [x, y, z], xs, ys, zs);
|
|
933
|
+
}
|
|
934
|
+
export function sortWith(comparer, xs) {
|
|
935
|
+
const arr = toArray(xs);
|
|
936
|
+
arr.sort(comparer);
|
|
937
|
+
return ofArray(arr);
|
|
938
|
+
}
|
|
939
|
+
export function sort(xs, comparer) {
|
|
940
|
+
return sortWith((x, y) => comparer.Compare(x, y), xs);
|
|
941
|
+
}
|
|
942
|
+
export function sortBy(projection, xs, comparer) {
|
|
943
|
+
return sortWith((x, y) => comparer.Compare(projection(x), projection(y)), xs);
|
|
944
|
+
}
|
|
945
|
+
export function sortDescending(xs, comparer) {
|
|
946
|
+
return sortWith((x, y) => (comparer.Compare(x, y) * -1), xs);
|
|
947
|
+
}
|
|
948
|
+
export function sortByDescending(projection, xs, comparer) {
|
|
949
|
+
return sortWith((x, y) => (comparer.Compare(projection(x), projection(y)) * -1), xs);
|
|
950
|
+
}
|
|
951
|
+
export function sum(xs, adder) {
|
|
952
|
+
return fold((acc, x) => adder.Add(acc, x), adder.GetZero(), xs);
|
|
953
|
+
}
|
|
954
|
+
export function sumBy(f, xs, adder) {
|
|
955
|
+
return fold((acc, x) => adder.Add(acc, f(x)), adder.GetZero(), xs);
|
|
956
|
+
}
|
|
957
|
+
export function maxBy(projection, xs, comparer) {
|
|
958
|
+
return reduce((x, y) => ((comparer.Compare(projection(y), projection(x)) > 0) ? y : x), xs);
|
|
959
|
+
}
|
|
960
|
+
export function max(xs, comparer) {
|
|
961
|
+
return reduce((x, y) => ((comparer.Compare(y, x) > 0) ? y : x), xs);
|
|
962
|
+
}
|
|
963
|
+
export function minBy(projection, xs, comparer) {
|
|
964
|
+
return reduce((x, y) => ((comparer.Compare(projection(y), projection(x)) > 0) ? x : y), xs);
|
|
965
|
+
}
|
|
966
|
+
export function min(xs, comparer) {
|
|
967
|
+
return reduce((x, y) => ((comparer.Compare(y, x) > 0) ? x : y), xs);
|
|
968
|
+
}
|
|
969
|
+
export function average(xs, averager) {
|
|
970
|
+
let count = 0;
|
|
971
|
+
const total = fold((acc, x) => {
|
|
972
|
+
count = ((count + 1) | 0);
|
|
973
|
+
return averager.Add(acc, x);
|
|
974
|
+
}, averager.GetZero(), xs);
|
|
975
|
+
return averager.DivideByInt(total, count);
|
|
976
|
+
}
|
|
977
|
+
export function averageBy(f, xs, averager) {
|
|
978
|
+
let count = 0;
|
|
979
|
+
const total = fold((acc, x) => {
|
|
980
|
+
count = ((count + 1) | 0);
|
|
981
|
+
return averager.Add(acc, f(x));
|
|
982
|
+
}, averager.GetZero(), xs);
|
|
983
|
+
return averager.DivideByInt(total, count);
|
|
984
|
+
}
|
|
985
|
+
export function permute(f, xs) {
|
|
986
|
+
return ofArray(permute_1(f, toArray(xs)));
|
|
987
|
+
}
|
|
988
|
+
export function chunkBySize(chunkSize, xs) {
|
|
989
|
+
return ofArray(map_1(ofArray, chunkBySize_1(chunkSize, toArray(xs))));
|
|
990
|
+
}
|
|
991
|
+
export function allPairs(xs, ys) {
|
|
992
|
+
const root = FSharpList_get_Empty();
|
|
993
|
+
let node = root;
|
|
994
|
+
iterate((x) => {
|
|
995
|
+
iterate((y) => {
|
|
996
|
+
let xs_1, t;
|
|
997
|
+
node = ((xs_1 = node, (t = (new FSharpList([x, y], undefined)), (xs_1.tail = t, t))));
|
|
998
|
+
}, ys);
|
|
999
|
+
}, xs);
|
|
1000
|
+
const xs_3 = node;
|
|
1001
|
+
const t_2 = FSharpList_get_Empty();
|
|
1002
|
+
xs_3.tail = t_2;
|
|
1003
|
+
return FSharpList__get_Tail(root);
|
|
1004
|
+
}
|
|
1005
|
+
export function skip(count_mut, xs_mut) {
|
|
1006
|
+
skip: while (true) {
|
|
1007
|
+
const count = count_mut, xs = xs_mut;
|
|
1008
|
+
if (count <= 0) {
|
|
1009
|
+
return xs;
|
|
1010
|
+
}
|
|
1011
|
+
else if (FSharpList__get_IsEmpty(xs)) {
|
|
1012
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "list");
|
|
1013
|
+
}
|
|
1014
|
+
else {
|
|
1015
|
+
count_mut = (count - 1);
|
|
1016
|
+
xs_mut = FSharpList__get_Tail(xs);
|
|
1017
|
+
continue skip;
|
|
1018
|
+
}
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
export function skipWhile(predicate_mut, xs_mut) {
|
|
1023
|
+
skipWhile: while (true) {
|
|
1024
|
+
const predicate = predicate_mut, xs = xs_mut;
|
|
1025
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
1026
|
+
return xs;
|
|
1027
|
+
}
|
|
1028
|
+
else if (!predicate(FSharpList__get_Head(xs))) {
|
|
1029
|
+
return xs;
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
predicate_mut = predicate;
|
|
1033
|
+
xs_mut = FSharpList__get_Tail(xs);
|
|
1034
|
+
continue skipWhile;
|
|
1035
|
+
}
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
export function take(count, xs) {
|
|
1040
|
+
if (count < 0) {
|
|
1041
|
+
throw new Error((SR_inputMustBeNonNegative + "\\nParameter name: ") + "count");
|
|
1042
|
+
}
|
|
1043
|
+
const loop = (i_mut, acc_mut, xs_1_mut) => {
|
|
1044
|
+
let t;
|
|
1045
|
+
loop: while (true) {
|
|
1046
|
+
const i = i_mut, acc = acc_mut, xs_1 = xs_1_mut;
|
|
1047
|
+
if (i <= 0) {
|
|
1048
|
+
return acc;
|
|
1049
|
+
}
|
|
1050
|
+
else if (FSharpList__get_IsEmpty(xs_1)) {
|
|
1051
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "list");
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
i_mut = (i - 1);
|
|
1055
|
+
acc_mut = ((t = (new FSharpList(FSharpList__get_Head(xs_1), undefined)), (acc.tail = t, t)));
|
|
1056
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
1057
|
+
continue loop;
|
|
1058
|
+
}
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
const root = FSharpList_get_Empty();
|
|
1063
|
+
const node = loop(count, root, xs);
|
|
1064
|
+
const t_2 = FSharpList_get_Empty();
|
|
1065
|
+
node.tail = t_2;
|
|
1066
|
+
return FSharpList__get_Tail(root);
|
|
1067
|
+
}
|
|
1068
|
+
export function takeWhile(predicate, xs) {
|
|
1069
|
+
const loop = (acc_mut, xs_1_mut) => {
|
|
1070
|
+
let t;
|
|
1071
|
+
loop: while (true) {
|
|
1072
|
+
const acc = acc_mut, xs_1 = xs_1_mut;
|
|
1073
|
+
if (FSharpList__get_IsEmpty(xs_1)) {
|
|
1074
|
+
return acc;
|
|
1075
|
+
}
|
|
1076
|
+
else if (!predicate(FSharpList__get_Head(xs_1))) {
|
|
1077
|
+
return acc;
|
|
1078
|
+
}
|
|
1079
|
+
else {
|
|
1080
|
+
acc_mut = ((t = (new FSharpList(FSharpList__get_Head(xs_1), undefined)), (acc.tail = t, t)));
|
|
1081
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
1082
|
+
continue loop;
|
|
1083
|
+
}
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
const root = FSharpList_get_Empty();
|
|
1088
|
+
const node = loop(root, xs);
|
|
1089
|
+
const t_2 = FSharpList_get_Empty();
|
|
1090
|
+
node.tail = t_2;
|
|
1091
|
+
return FSharpList__get_Tail(root);
|
|
1092
|
+
}
|
|
1093
|
+
export function truncate(count, xs) {
|
|
1094
|
+
const loop = (i_mut, acc_mut, xs_1_mut) => {
|
|
1095
|
+
let t;
|
|
1096
|
+
loop: while (true) {
|
|
1097
|
+
const i = i_mut, acc = acc_mut, xs_1 = xs_1_mut;
|
|
1098
|
+
if (i <= 0) {
|
|
1099
|
+
return acc;
|
|
1100
|
+
}
|
|
1101
|
+
else if (FSharpList__get_IsEmpty(xs_1)) {
|
|
1102
|
+
return acc;
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
i_mut = (i - 1);
|
|
1106
|
+
acc_mut = ((t = (new FSharpList(FSharpList__get_Head(xs_1), undefined)), (acc.tail = t, t)));
|
|
1107
|
+
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
1108
|
+
continue loop;
|
|
1109
|
+
}
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
const root = FSharpList_get_Empty();
|
|
1114
|
+
const node = loop(count, root, xs);
|
|
1115
|
+
const t_2 = FSharpList_get_Empty();
|
|
1116
|
+
node.tail = t_2;
|
|
1117
|
+
return FSharpList__get_Tail(root);
|
|
1118
|
+
}
|
|
1119
|
+
export function getSlice(startIndex, endIndex, xs) {
|
|
1120
|
+
const len = length(xs) | 0;
|
|
1121
|
+
let startIndex_1;
|
|
1122
|
+
const index = defaultArg(startIndex, 0) | 0;
|
|
1123
|
+
startIndex_1 = ((index < 0) ? 0 : index);
|
|
1124
|
+
let endIndex_1;
|
|
1125
|
+
const index_1 = defaultArg(endIndex, len - 1) | 0;
|
|
1126
|
+
endIndex_1 = ((index_1 >= len) ? (len - 1) : index_1);
|
|
1127
|
+
if (endIndex_1 < startIndex_1) {
|
|
1128
|
+
return FSharpList_get_Empty();
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
return take((endIndex_1 - startIndex_1) + 1, skip(startIndex_1, xs));
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
export function splitAt(index, xs) {
|
|
1135
|
+
if (index < 0) {
|
|
1136
|
+
throw new Error((SR_inputMustBeNonNegative + "\\nParameter name: ") + "index");
|
|
1137
|
+
}
|
|
1138
|
+
if (index > FSharpList__get_Length(xs)) {
|
|
1139
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "index");
|
|
1140
|
+
}
|
|
1141
|
+
return [take(index, xs), skip(index, xs)];
|
|
1142
|
+
}
|
|
1143
|
+
export function exactlyOne(xs) {
|
|
1144
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
1145
|
+
throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "list");
|
|
1146
|
+
}
|
|
1147
|
+
else if (FSharpList__get_IsEmpty(FSharpList__get_Tail(xs))) {
|
|
1148
|
+
return FSharpList__get_Head(xs);
|
|
1149
|
+
}
|
|
1150
|
+
else {
|
|
1151
|
+
throw new Error((SR_inputSequenceTooLong + "\\nParameter name: ") + "list");
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
export function tryExactlyOne(xs) {
|
|
1155
|
+
if (!FSharpList__get_IsEmpty(xs) && FSharpList__get_IsEmpty(FSharpList__get_Tail(xs))) {
|
|
1156
|
+
return some(FSharpList__get_Head(xs));
|
|
1157
|
+
}
|
|
1158
|
+
else {
|
|
1159
|
+
return undefined;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
export function where(predicate, xs) {
|
|
1163
|
+
return filter(predicate, xs);
|
|
1164
|
+
}
|
|
1165
|
+
export function pairwise(xs) {
|
|
1166
|
+
return ofArray(pairwise_1(toArray(xs)));
|
|
1167
|
+
}
|
|
1168
|
+
export function windowed(windowSize, xs) {
|
|
1169
|
+
return ofArray(map_1(ofArray, windowed_1(windowSize, toArray(xs))));
|
|
1170
|
+
}
|
|
1171
|
+
export function splitInto(chunks, xs) {
|
|
1172
|
+
return ofArray(map_1(ofArray, splitInto_1(chunks, toArray(xs))));
|
|
1173
|
+
}
|
|
1174
|
+
export function transpose(lists) {
|
|
1175
|
+
return ofArray(map_1(ofArray, transpose_1(map_1(toArray, Array.from(lists)))));
|
|
1176
|
+
}
|
|
1177
|
+
export function insertAt(index, y, xs) {
|
|
1178
|
+
let i = -1;
|
|
1179
|
+
let isDone = false;
|
|
1180
|
+
const result = fold((acc, x) => {
|
|
1181
|
+
i = ((i + 1) | 0);
|
|
1182
|
+
if (i === index) {
|
|
1183
|
+
isDone = true;
|
|
1184
|
+
return FSharpList_Cons_305B8EAC(x, FSharpList_Cons_305B8EAC(y, acc));
|
|
1185
|
+
}
|
|
1186
|
+
else {
|
|
1187
|
+
return FSharpList_Cons_305B8EAC(x, acc);
|
|
1188
|
+
}
|
|
1189
|
+
}, FSharpList_get_Empty(), xs);
|
|
1190
|
+
return reverse(isDone ? result : (((i + 1) === index) ? FSharpList_Cons_305B8EAC(y, result) : (() => {
|
|
1191
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1192
|
+
})()));
|
|
1193
|
+
}
|
|
1194
|
+
export function insertManyAt(index, ys, xs) {
|
|
1195
|
+
let i = -1;
|
|
1196
|
+
let isDone = false;
|
|
1197
|
+
const ys_1 = ofSeq(ys);
|
|
1198
|
+
const result = fold((acc, x) => {
|
|
1199
|
+
i = ((i + 1) | 0);
|
|
1200
|
+
if (i === index) {
|
|
1201
|
+
isDone = true;
|
|
1202
|
+
return FSharpList_Cons_305B8EAC(x, append(ys_1, acc));
|
|
1203
|
+
}
|
|
1204
|
+
else {
|
|
1205
|
+
return FSharpList_Cons_305B8EAC(x, acc);
|
|
1206
|
+
}
|
|
1207
|
+
}, FSharpList_get_Empty(), xs);
|
|
1208
|
+
return reverse(isDone ? result : (((i + 1) === index) ? append(ys_1, result) : (() => {
|
|
1209
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1210
|
+
})()));
|
|
1211
|
+
}
|
|
1212
|
+
export function removeAt(index, xs) {
|
|
1213
|
+
let i = -1;
|
|
1214
|
+
let isDone = false;
|
|
1215
|
+
const ys = filter((_arg) => {
|
|
1216
|
+
i = ((i + 1) | 0);
|
|
1217
|
+
if (i === index) {
|
|
1218
|
+
isDone = true;
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
else {
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
}, xs);
|
|
1225
|
+
if (!isDone) {
|
|
1226
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1227
|
+
}
|
|
1228
|
+
return ys;
|
|
1229
|
+
}
|
|
1230
|
+
export function removeManyAt(index, count, xs) {
|
|
1231
|
+
let i = -1;
|
|
1232
|
+
let status = -1;
|
|
1233
|
+
const ys = filter((_arg) => {
|
|
1234
|
+
i = ((i + 1) | 0);
|
|
1235
|
+
if (i === index) {
|
|
1236
|
+
status = 0;
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
else if (i > index) {
|
|
1240
|
+
if (i < (index + count)) {
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
status = 1;
|
|
1245
|
+
return true;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
else {
|
|
1249
|
+
return true;
|
|
1250
|
+
}
|
|
1251
|
+
}, xs);
|
|
1252
|
+
const status_1 = (((status === 0) && ((i + 1) === (index + count))) ? 1 : status) | 0;
|
|
1253
|
+
if (status_1 < 1) {
|
|
1254
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + ((status_1 < 0) ? "index" : "count"));
|
|
1255
|
+
}
|
|
1256
|
+
return ys;
|
|
1257
|
+
}
|
|
1258
|
+
export function updateAt(index, y, xs) {
|
|
1259
|
+
let isDone = false;
|
|
1260
|
+
const ys = mapIndexed((i, x) => {
|
|
1261
|
+
if (i === index) {
|
|
1262
|
+
isDone = true;
|
|
1263
|
+
return y;
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
return x;
|
|
1267
|
+
}
|
|
1268
|
+
}, xs);
|
|
1269
|
+
if (!isDone) {
|
|
1270
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1271
|
+
}
|
|
1272
|
+
return ys;
|
|
1273
|
+
}
|