@fable-org/fable-library-js 2.10.0 → 2.12.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/Array.js +272 -167
- package/BigInt.js +18 -6
- package/CHANGELOG.md +42 -1
- package/Date.js +1 -1
- package/Decimal.js +16 -46
- package/Double.js +25 -10
- package/FSharp.Core.js +7 -1
- package/Global.js +1 -1
- package/Int32.js +10 -1
- package/List.js +226 -156
- package/Long.js +7 -2
- package/Map.js +46 -39
- package/MutableMap.js +76 -96
- package/MutableSet.js +58 -80
- package/NumberStyles.js +56 -0
- package/Numeric.js +10 -4
- package/Random.js +3 -4
- package/Range.js +4 -3
- package/RegExp.js +3 -2
- package/Seq.js +132 -64
- package/Seq2.js +4 -8
- package/Set.js +64 -57
- package/String.js +71 -23
- package/System.Collections.Generic.js +3 -2
- package/System.Text.js +2 -2
- package/System.js +5 -5
- package/TimeOnly.js +1 -1
- package/Types.js +25 -10
- package/Util.js +91 -48
- package/package.json +1 -1
package/List.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { isArrayLike,
|
|
2
|
-
import {
|
|
3
|
-
import { defaultArg,
|
|
4
|
-
import { class_type
|
|
5
|
-
import {
|
|
1
|
+
import { isArrayLike, defaultOf, toIterator, compare, structuralHash, equals, disposeSafe, getEnumerator } from "./Util.js";
|
|
2
|
+
import { toString } from "./Types.js";
|
|
3
|
+
import { defaultArg, value as value_1, some } from "./Option.js";
|
|
4
|
+
import { class_type } from "./Reflection.js";
|
|
5
|
+
import { Operators_InvalidArg, Operators_InvalidOp } from "./FSharp.Core.js";
|
|
6
|
+
import { SR_inputSequenceTooLong, SR_notEnoughElements, SR_inputSequenceEmpty, SR_inputMustBeNonNegative, SR_keyNotFoundAlt, SR_indexOutOfBounds, SR_inputWasEmpty } from "./Global.js";
|
|
6
7
|
import { KeyNotFoundException_$ctor_Z721C83C5 } from "./System.Collections.Generic.js";
|
|
7
8
|
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.js";
|
|
9
|
+
import { ArgumentOutOfRangeException_$ctor_Z384F8060 } from "./System.js";
|
|
8
10
|
import { nonSeeded } from "./Random.js";
|
|
9
|
-
export class FSharpList
|
|
11
|
+
export class FSharpList {
|
|
10
12
|
constructor(head, tail) {
|
|
11
|
-
super();
|
|
12
13
|
this.head = head;
|
|
13
14
|
this.tail = tail;
|
|
14
15
|
}
|
|
@@ -44,8 +45,8 @@ export class FSharpList extends Record {
|
|
|
44
45
|
const matchValue_1 = ys_1.tail;
|
|
45
46
|
if (matchValue != null) {
|
|
46
47
|
if (matchValue_1 != null) {
|
|
47
|
-
const xt =
|
|
48
|
-
const yt =
|
|
48
|
+
const xt = matchValue;
|
|
49
|
+
const yt = matchValue_1;
|
|
49
50
|
if (equals(xs_1.head, ys_1.head)) {
|
|
50
51
|
xs_1_mut = xt;
|
|
51
52
|
ys_1_mut = yt;
|
|
@@ -81,7 +82,7 @@ export class FSharpList extends Record {
|
|
|
81
82
|
const i = i_mut, h = h_mut, xs_1 = xs_1_mut;
|
|
82
83
|
const matchValue = xs_1.tail;
|
|
83
84
|
if (matchValue != null) {
|
|
84
|
-
const t =
|
|
85
|
+
const t = matchValue;
|
|
85
86
|
if (i > 18) {
|
|
86
87
|
return h | 0;
|
|
87
88
|
}
|
|
@@ -115,8 +116,8 @@ export class FSharpList extends Record {
|
|
|
115
116
|
const matchValue_1 = ys_1.tail;
|
|
116
117
|
if (matchValue != null) {
|
|
117
118
|
if (matchValue_1 != null) {
|
|
118
|
-
const xt =
|
|
119
|
-
const yt =
|
|
119
|
+
const xt = matchValue;
|
|
120
|
+
const yt = matchValue_1;
|
|
120
121
|
const c = compare(xs_1.head, ys_1.head) | 0;
|
|
121
122
|
if (c === 0) {
|
|
122
123
|
xs_1_mut = xt;
|
|
@@ -159,7 +160,7 @@ export class FSharpList extends Record {
|
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
export function FSharpList_$reflection(gen0) {
|
|
162
|
-
return
|
|
163
|
+
return class_type("ListModule.FSharpList", [gen0], FSharpList);
|
|
163
164
|
}
|
|
164
165
|
export class ListEnumerator$1 {
|
|
165
166
|
constructor(xs) {
|
|
@@ -179,7 +180,7 @@ export class ListEnumerator$1 {
|
|
|
179
180
|
const _ = this;
|
|
180
181
|
const matchValue = _.it.tail;
|
|
181
182
|
if (matchValue != null) {
|
|
182
|
-
const t =
|
|
183
|
+
const t = matchValue;
|
|
183
184
|
_.current = _.it.head;
|
|
184
185
|
_.it = t;
|
|
185
186
|
return true;
|
|
@@ -202,11 +203,8 @@ export function ListEnumerator$1_$reflection(gen0) {
|
|
|
202
203
|
export function ListEnumerator$1_$ctor_3002E699(xs) {
|
|
203
204
|
return new ListEnumerator$1(xs);
|
|
204
205
|
}
|
|
205
|
-
export function
|
|
206
|
-
return new FSharpList(
|
|
207
|
-
}
|
|
208
|
-
export function FSharpList_Cons_305B8EAC(x, xs) {
|
|
209
|
-
return new FSharpList(x, xs);
|
|
206
|
+
export function FSharpList_$ctor_Z23DD7291(head_1, tail_1) {
|
|
207
|
+
return new FSharpList(head_1, tail_1);
|
|
210
208
|
}
|
|
211
209
|
export function FSharpList__get_IsEmpty(xs) {
|
|
212
210
|
return xs.tail == null;
|
|
@@ -218,7 +216,7 @@ export function FSharpList__get_Length(xs) {
|
|
|
218
216
|
const matchValue = xs_1.tail;
|
|
219
217
|
if (matchValue != null) {
|
|
220
218
|
i_mut = (i + 1);
|
|
221
|
-
xs_1_mut =
|
|
219
|
+
xs_1_mut = matchValue;
|
|
222
220
|
continue loop;
|
|
223
221
|
}
|
|
224
222
|
else {
|
|
@@ -235,16 +233,16 @@ export function FSharpList__get_Head(xs) {
|
|
|
235
233
|
return xs.head;
|
|
236
234
|
}
|
|
237
235
|
else {
|
|
238
|
-
throw
|
|
236
|
+
throw Operators_InvalidOp(SR_inputWasEmpty);
|
|
239
237
|
}
|
|
240
238
|
}
|
|
241
239
|
export function FSharpList__get_Tail(xs) {
|
|
242
240
|
const matchValue = xs.tail;
|
|
243
241
|
if (matchValue != null) {
|
|
244
|
-
return
|
|
242
|
+
return matchValue;
|
|
245
243
|
}
|
|
246
244
|
else {
|
|
247
|
-
throw
|
|
245
|
+
throw Operators_InvalidOp(SR_inputWasEmpty);
|
|
248
246
|
}
|
|
249
247
|
}
|
|
250
248
|
export function FSharpList__get_Item_Z524259A4(xs, index) {
|
|
@@ -253,7 +251,7 @@ export function FSharpList__get_Item_Z524259A4(xs, index) {
|
|
|
253
251
|
const i = i_mut, xs_1 = xs_1_mut;
|
|
254
252
|
const matchValue = xs_1.tail;
|
|
255
253
|
if (matchValue != null) {
|
|
256
|
-
const t =
|
|
254
|
+
const t = matchValue;
|
|
257
255
|
if (i === index) {
|
|
258
256
|
return xs_1.head;
|
|
259
257
|
}
|
|
@@ -264,24 +262,28 @@ export function FSharpList__get_Item_Z524259A4(xs, index) {
|
|
|
264
262
|
}
|
|
265
263
|
}
|
|
266
264
|
else {
|
|
267
|
-
throw
|
|
265
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
268
266
|
}
|
|
269
267
|
break;
|
|
270
268
|
}
|
|
271
269
|
};
|
|
272
270
|
return loop(0, xs);
|
|
273
271
|
}
|
|
272
|
+
const emptyNode = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
273
|
+
export function empty() {
|
|
274
|
+
return emptyNode;
|
|
275
|
+
}
|
|
274
276
|
export function indexNotFound() {
|
|
275
277
|
throw KeyNotFoundException_$ctor_Z721C83C5(SR_keyNotFoundAlt);
|
|
276
278
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
+
function differentLengths(paramName) {
|
|
280
|
+
throw Operators_InvalidArg(paramName, "The lists had different lengths.");
|
|
279
281
|
}
|
|
280
282
|
export function cons(x, xs) {
|
|
281
|
-
return
|
|
283
|
+
return FSharpList_$ctor_Z23DD7291(x, xs);
|
|
282
284
|
}
|
|
283
285
|
export function singleton(x) {
|
|
284
|
-
return
|
|
286
|
+
return FSharpList_$ctor_Z23DD7291(x, empty());
|
|
285
287
|
}
|
|
286
288
|
export function isEmpty(xs) {
|
|
287
289
|
return FSharpList__get_IsEmpty(xs);
|
|
@@ -290,7 +292,13 @@ export function length(xs) {
|
|
|
290
292
|
return FSharpList__get_Length(xs) | 0;
|
|
291
293
|
}
|
|
292
294
|
export function head(xs) {
|
|
293
|
-
|
|
295
|
+
const matchValue = xs.tail;
|
|
296
|
+
if (matchValue != null) {
|
|
297
|
+
return xs.head;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
throw Operators_InvalidArg("list", SR_inputWasEmpty);
|
|
301
|
+
}
|
|
294
302
|
}
|
|
295
303
|
export function tryHead(xs) {
|
|
296
304
|
if (FSharpList__get_IsEmpty(xs)) {
|
|
@@ -301,7 +309,13 @@ export function tryHead(xs) {
|
|
|
301
309
|
}
|
|
302
310
|
}
|
|
303
311
|
export function tail(xs) {
|
|
304
|
-
|
|
312
|
+
const matchValue = xs.tail;
|
|
313
|
+
if (matchValue != null) {
|
|
314
|
+
return matchValue;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
throw Operators_InvalidArg("list", SR_inputWasEmpty);
|
|
318
|
+
}
|
|
305
319
|
}
|
|
306
320
|
export function tryLast(xs_mut) {
|
|
307
321
|
tryLast: while (true) {
|
|
@@ -325,7 +339,7 @@ export function tryLast(xs_mut) {
|
|
|
325
339
|
export function last(xs) {
|
|
326
340
|
const matchValue = tryLast(xs);
|
|
327
341
|
if (matchValue == null) {
|
|
328
|
-
throw
|
|
342
|
+
throw Operators_InvalidArg("list", SR_inputWasEmpty);
|
|
329
343
|
}
|
|
330
344
|
else {
|
|
331
345
|
return value_1(matchValue);
|
|
@@ -392,7 +406,7 @@ export function fold(folder, state, xs) {
|
|
|
392
406
|
return acc;
|
|
393
407
|
}
|
|
394
408
|
export function reverse(xs) {
|
|
395
|
-
return fold((acc, x) =>
|
|
409
|
+
return fold((acc, x) => FSharpList_$ctor_Z23DD7291(x, acc), empty(), xs);
|
|
396
410
|
}
|
|
397
411
|
export function foldBack(folder, xs, state) {
|
|
398
412
|
return foldBack_1(folder, toArray(xs), state);
|
|
@@ -424,10 +438,21 @@ export function fold2(folder, state, xs, ys) {
|
|
|
424
438
|
xs_1 = FSharpList__get_Tail(xs_1);
|
|
425
439
|
ys_1 = FSharpList__get_Tail(ys_1);
|
|
426
440
|
}
|
|
441
|
+
if (!FSharpList__get_IsEmpty(xs_1)) {
|
|
442
|
+
differentLengths("list2");
|
|
443
|
+
}
|
|
444
|
+
else if (!FSharpList__get_IsEmpty(ys_1)) {
|
|
445
|
+
differentLengths("list1");
|
|
446
|
+
}
|
|
427
447
|
return acc;
|
|
428
448
|
}
|
|
429
449
|
export function foldBack2(folder, xs, ys, state) {
|
|
430
|
-
|
|
450
|
+
const xs_1 = toArray(xs);
|
|
451
|
+
const ys_1 = toArray(ys);
|
|
452
|
+
if (xs_1.length !== ys_1.length) {
|
|
453
|
+
differentLengths((xs_1.length === 0) ? "list1" : ((ys_1.length === 0) ? "list2" : "list1, list2"));
|
|
454
|
+
}
|
|
455
|
+
return foldBack2_1(folder, xs_1, ys_1, state);
|
|
431
456
|
}
|
|
432
457
|
export function unfold(generator, state) {
|
|
433
458
|
const loop = (acc_mut, node_mut) => {
|
|
@@ -436,8 +461,8 @@ export function unfold(generator, state) {
|
|
|
436
461
|
let t = undefined;
|
|
437
462
|
const matchValue = generator(acc);
|
|
438
463
|
if (matchValue != null) {
|
|
439
|
-
acc_mut =
|
|
440
|
-
node_mut = ((t = (
|
|
464
|
+
acc_mut = matchValue[1];
|
|
465
|
+
node_mut = ((t = FSharpList_$ctor_Z23DD7291(matchValue[0], undefined), (node.tail = t, t)));
|
|
441
466
|
continue loop;
|
|
442
467
|
}
|
|
443
468
|
else {
|
|
@@ -446,9 +471,9 @@ export function unfold(generator, state) {
|
|
|
446
471
|
break;
|
|
447
472
|
}
|
|
448
473
|
};
|
|
449
|
-
const root =
|
|
474
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
450
475
|
const node_1 = loop(state, root);
|
|
451
|
-
const t_2 =
|
|
476
|
+
const t_2 = empty();
|
|
452
477
|
node_1.tail = t_2;
|
|
453
478
|
return FSharpList__get_Tail(root);
|
|
454
479
|
}
|
|
@@ -480,12 +505,12 @@ export function toSeq(xs) {
|
|
|
480
505
|
export function ofArrayWithTail(xs, tail_1) {
|
|
481
506
|
let res = tail_1;
|
|
482
507
|
for (let i = xs.length - 1; i >= 0; i--) {
|
|
483
|
-
res =
|
|
508
|
+
res = FSharpList_$ctor_Z23DD7291(item_1(i, xs), res);
|
|
484
509
|
}
|
|
485
510
|
return res;
|
|
486
511
|
}
|
|
487
512
|
export function ofArray(xs) {
|
|
488
|
-
return ofArrayWithTail(xs,
|
|
513
|
+
return ofArrayWithTail(xs, empty());
|
|
489
514
|
}
|
|
490
515
|
export function ofSeq(xs) {
|
|
491
516
|
if (isArrayLike(xs)) {
|
|
@@ -495,31 +520,31 @@ export function ofSeq(xs) {
|
|
|
495
520
|
return xs;
|
|
496
521
|
}
|
|
497
522
|
else {
|
|
498
|
-
const root =
|
|
523
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
499
524
|
let node = root;
|
|
500
525
|
const enumerator = getEnumerator(xs);
|
|
501
526
|
try {
|
|
502
527
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
503
528
|
let xs_3 = undefined, t = undefined;
|
|
504
|
-
const
|
|
505
|
-
node = ((xs_3 = node, (t = (
|
|
529
|
+
const x_1 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
530
|
+
node = ((xs_3 = node, (t = FSharpList_$ctor_Z23DD7291(x_1, undefined), (xs_3.tail = t, t))));
|
|
506
531
|
}
|
|
507
532
|
}
|
|
508
533
|
finally {
|
|
509
534
|
disposeSafe(enumerator);
|
|
510
535
|
}
|
|
511
536
|
const xs_5 = node;
|
|
512
|
-
const t_2 =
|
|
537
|
+
const t_2 = empty();
|
|
513
538
|
xs_5.tail = t_2;
|
|
514
539
|
return FSharpList__get_Tail(root);
|
|
515
540
|
}
|
|
516
541
|
}
|
|
517
542
|
export function concat(lists) {
|
|
518
|
-
const root =
|
|
543
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
519
544
|
let node = root;
|
|
520
545
|
const action = (xs) => {
|
|
521
|
-
node = fold((acc,
|
|
522
|
-
const t =
|
|
546
|
+
node = fold((acc, x_1) => {
|
|
547
|
+
const t = FSharpList_$ctor_Z23DD7291(x_1, undefined);
|
|
523
548
|
acc.tail = t;
|
|
524
549
|
return t;
|
|
525
550
|
}, node, xs);
|
|
@@ -543,14 +568,14 @@ export function concat(lists) {
|
|
|
543
568
|
}
|
|
544
569
|
}
|
|
545
570
|
const xs_6 = node;
|
|
546
|
-
const t_2 =
|
|
571
|
+
const t_2 = empty();
|
|
547
572
|
xs_6.tail = t_2;
|
|
548
573
|
return FSharpList__get_Tail(root);
|
|
549
574
|
}
|
|
550
575
|
export function scan(folder, state, xs) {
|
|
551
|
-
const root =
|
|
576
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
552
577
|
let node;
|
|
553
|
-
const t =
|
|
578
|
+
const t = FSharpList_$ctor_Z23DD7291(state, undefined);
|
|
554
579
|
root.tail = t;
|
|
555
580
|
node = t;
|
|
556
581
|
let acc = state;
|
|
@@ -558,11 +583,11 @@ export function scan(folder, state, xs) {
|
|
|
558
583
|
while (!FSharpList__get_IsEmpty(xs_3)) {
|
|
559
584
|
let xs_4 = undefined, t_2 = undefined;
|
|
560
585
|
acc = folder(acc, FSharpList__get_Head(xs_3));
|
|
561
|
-
node = ((xs_4 = node, (t_2 = (
|
|
586
|
+
node = ((xs_4 = node, (t_2 = FSharpList_$ctor_Z23DD7291(acc, undefined), (xs_4.tail = t_2, t_2))));
|
|
562
587
|
xs_3 = FSharpList__get_Tail(xs_3);
|
|
563
588
|
}
|
|
564
589
|
const xs_6 = node;
|
|
565
|
-
const t_4 =
|
|
590
|
+
const t_4 = empty();
|
|
566
591
|
xs_6.tail = t_4;
|
|
567
592
|
return FSharpList__get_Tail(root);
|
|
568
593
|
}
|
|
@@ -570,45 +595,55 @@ export function scanBack(folder, xs, state) {
|
|
|
570
595
|
return ofArray(scanBack_1(folder, toArray(xs), state));
|
|
571
596
|
}
|
|
572
597
|
export function append(xs, ys) {
|
|
573
|
-
|
|
598
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
599
|
+
let node = root;
|
|
600
|
+
let rest = xs;
|
|
601
|
+
while (rest.tail != null) {
|
|
602
|
+
let xs_1 = undefined, t = undefined;
|
|
603
|
+
node = ((xs_1 = node, (t = FSharpList_$ctor_Z23DD7291(rest.head, undefined), (xs_1.tail = t, t))));
|
|
604
|
+
rest = rest.tail;
|
|
605
|
+
}
|
|
606
|
+
const xs_3 = node;
|
|
607
|
+
xs_3.tail = ys;
|
|
608
|
+
return FSharpList__get_Tail(root);
|
|
574
609
|
}
|
|
575
610
|
export function collect(mapping, xs) {
|
|
576
|
-
const root =
|
|
611
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
577
612
|
let node = root;
|
|
578
613
|
let ys = xs;
|
|
579
614
|
while (!FSharpList__get_IsEmpty(ys)) {
|
|
580
615
|
let zs = mapping(FSharpList__get_Head(ys));
|
|
581
616
|
while (!FSharpList__get_IsEmpty(zs)) {
|
|
582
617
|
let xs_1 = undefined, t = undefined;
|
|
583
|
-
node = ((xs_1 = node, (t = (
|
|
618
|
+
node = ((xs_1 = node, (t = FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(zs), undefined), (xs_1.tail = t, t))));
|
|
584
619
|
zs = FSharpList__get_Tail(zs);
|
|
585
620
|
}
|
|
586
621
|
ys = FSharpList__get_Tail(ys);
|
|
587
622
|
}
|
|
588
623
|
const xs_3 = node;
|
|
589
|
-
const t_2 =
|
|
624
|
+
const t_2 = empty();
|
|
590
625
|
xs_3.tail = t_2;
|
|
591
626
|
return FSharpList__get_Tail(root);
|
|
592
627
|
}
|
|
593
628
|
export function mapIndexed(mapping, xs) {
|
|
594
|
-
const root =
|
|
595
|
-
const node = foldIndexed((i, acc,
|
|
596
|
-
const t =
|
|
629
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
630
|
+
const node = foldIndexed((i, acc, x_1) => {
|
|
631
|
+
const t = FSharpList_$ctor_Z23DD7291(mapping(i, x_1), undefined);
|
|
597
632
|
acc.tail = t;
|
|
598
633
|
return t;
|
|
599
634
|
}, root, xs);
|
|
600
|
-
const t_2 =
|
|
635
|
+
const t_2 = empty();
|
|
601
636
|
node.tail = t_2;
|
|
602
637
|
return FSharpList__get_Tail(root);
|
|
603
638
|
}
|
|
604
639
|
export function map(mapping, xs) {
|
|
605
|
-
const root =
|
|
606
|
-
const node = fold((acc,
|
|
607
|
-
const t =
|
|
640
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
641
|
+
const node = fold((acc, x_1) => {
|
|
642
|
+
const t = FSharpList_$ctor_Z23DD7291(mapping(x_1), undefined);
|
|
608
643
|
acc.tail = t;
|
|
609
644
|
return t;
|
|
610
645
|
}, root, xs);
|
|
611
|
-
const t_2 =
|
|
646
|
+
const t_2 = empty();
|
|
612
647
|
node.tail = t_2;
|
|
613
648
|
return FSharpList__get_Tail(root);
|
|
614
649
|
}
|
|
@@ -616,13 +651,13 @@ export function indexed(xs) {
|
|
|
616
651
|
return mapIndexed((i, x) => [i, x], xs);
|
|
617
652
|
}
|
|
618
653
|
export function map2(mapping, xs, ys) {
|
|
619
|
-
const root =
|
|
620
|
-
const node = fold2((acc,
|
|
621
|
-
const t =
|
|
654
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
655
|
+
const node = fold2((acc, x_1, y) => {
|
|
656
|
+
const t = FSharpList_$ctor_Z23DD7291(mapping(x_1, y), undefined);
|
|
622
657
|
acc.tail = t;
|
|
623
658
|
return t;
|
|
624
659
|
}, root, xs, ys);
|
|
625
|
-
const t_2 =
|
|
660
|
+
const t_2 = empty();
|
|
626
661
|
node.tail = t_2;
|
|
627
662
|
return FSharpList__get_Tail(root);
|
|
628
663
|
}
|
|
@@ -632,11 +667,17 @@ export function mapIndexed2(mapping, xs, ys) {
|
|
|
632
667
|
const i = i_mut, acc = acc_mut, xs_1 = xs_1_mut, ys_1 = ys_1_mut;
|
|
633
668
|
let t = undefined;
|
|
634
669
|
if (FSharpList__get_IsEmpty(xs_1) ? true : FSharpList__get_IsEmpty(ys_1)) {
|
|
670
|
+
if (!FSharpList__get_IsEmpty(xs_1)) {
|
|
671
|
+
differentLengths("list2");
|
|
672
|
+
}
|
|
673
|
+
else if (!FSharpList__get_IsEmpty(ys_1)) {
|
|
674
|
+
differentLengths("list1");
|
|
675
|
+
}
|
|
635
676
|
return acc;
|
|
636
677
|
}
|
|
637
678
|
else {
|
|
638
679
|
i_mut = (i + 1);
|
|
639
|
-
acc_mut = ((t = (
|
|
680
|
+
acc_mut = ((t = FSharpList_$ctor_Z23DD7291(mapping(i, FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1)), undefined), (acc.tail = t, t)));
|
|
640
681
|
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
641
682
|
ys_1_mut = FSharpList__get_Tail(ys_1);
|
|
642
683
|
continue loop;
|
|
@@ -644,9 +685,9 @@ export function mapIndexed2(mapping, xs, ys) {
|
|
|
644
685
|
break;
|
|
645
686
|
}
|
|
646
687
|
};
|
|
647
|
-
const root =
|
|
688
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
648
689
|
const node_1 = loop(0, root, xs, ys);
|
|
649
|
-
const t_2 =
|
|
690
|
+
const t_2 = empty();
|
|
650
691
|
node_1.tail = t_2;
|
|
651
692
|
return FSharpList__get_Tail(root);
|
|
652
693
|
}
|
|
@@ -656,10 +697,13 @@ export function map3(mapping, xs, ys, zs) {
|
|
|
656
697
|
const acc = acc_mut, xs_1 = xs_1_mut, ys_1 = ys_1_mut, zs_1 = zs_1_mut;
|
|
657
698
|
let t = undefined;
|
|
658
699
|
if ((FSharpList__get_IsEmpty(xs_1) ? true : FSharpList__get_IsEmpty(ys_1)) ? true : FSharpList__get_IsEmpty(zs_1)) {
|
|
700
|
+
if (!((FSharpList__get_IsEmpty(xs_1) && FSharpList__get_IsEmpty(ys_1)) && FSharpList__get_IsEmpty(zs_1))) {
|
|
701
|
+
differentLengths("list1, list2, list3");
|
|
702
|
+
}
|
|
659
703
|
return acc;
|
|
660
704
|
}
|
|
661
705
|
else {
|
|
662
|
-
acc_mut = ((t = (
|
|
706
|
+
acc_mut = ((t = FSharpList_$ctor_Z23DD7291(mapping(FSharpList__get_Head(xs_1), FSharpList__get_Head(ys_1), FSharpList__get_Head(zs_1)), undefined), (acc.tail = t, t)));
|
|
663
707
|
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
664
708
|
ys_1_mut = FSharpList__get_Tail(ys_1);
|
|
665
709
|
zs_1_mut = FSharpList__get_Tail(zs_1);
|
|
@@ -668,20 +712,20 @@ export function map3(mapping, xs, ys, zs) {
|
|
|
668
712
|
break;
|
|
669
713
|
}
|
|
670
714
|
};
|
|
671
|
-
const root =
|
|
715
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
672
716
|
const node_1 = loop(root, xs, ys, zs);
|
|
673
|
-
const t_2 =
|
|
717
|
+
const t_2 = empty();
|
|
674
718
|
node_1.tail = t_2;
|
|
675
719
|
return FSharpList__get_Tail(root);
|
|
676
720
|
}
|
|
677
721
|
export function mapFold(mapping, state, xs) {
|
|
678
|
-
const root =
|
|
722
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
679
723
|
const patternInput_1 = fold((tupledArg, x) => {
|
|
680
724
|
let t = undefined;
|
|
681
725
|
const patternInput = mapping(tupledArg[1], x);
|
|
682
|
-
return [(t = (
|
|
726
|
+
return [(t = FSharpList_$ctor_Z23DD7291(patternInput[0], undefined), (tupledArg[0].tail = t, t)), patternInput[1]];
|
|
683
727
|
}, [root, state], xs);
|
|
684
|
-
const t_2 =
|
|
728
|
+
const t_2 = empty();
|
|
685
729
|
patternInput_1[0].tail = t_2;
|
|
686
730
|
return [FSharpList__get_Tail(root), patternInput_1[1]];
|
|
687
731
|
}
|
|
@@ -770,7 +814,7 @@ export function findIndex(f, xs) {
|
|
|
770
814
|
return -1;
|
|
771
815
|
}
|
|
772
816
|
else {
|
|
773
|
-
return
|
|
817
|
+
return matchValue | 0;
|
|
774
818
|
}
|
|
775
819
|
}
|
|
776
820
|
export function tryFindIndexBack(f, xs) {
|
|
@@ -783,7 +827,7 @@ export function findIndexBack(f, xs) {
|
|
|
783
827
|
return -1;
|
|
784
828
|
}
|
|
785
829
|
else {
|
|
786
|
-
return
|
|
830
|
+
return matchValue | 0;
|
|
787
831
|
}
|
|
788
832
|
}
|
|
789
833
|
export function tryItem(n, xs) {
|
|
@@ -810,10 +854,10 @@ export function item(n, xs) {
|
|
|
810
854
|
return FSharpList__get_Item_Z524259A4(xs, n);
|
|
811
855
|
}
|
|
812
856
|
export function filter(f, xs) {
|
|
813
|
-
const root =
|
|
814
|
-
const node = fold((acc,
|
|
815
|
-
if (f(
|
|
816
|
-
const t =
|
|
857
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
858
|
+
const node = fold((acc, x_1) => {
|
|
859
|
+
if (f(x_1)) {
|
|
860
|
+
const t = FSharpList_$ctor_Z23DD7291(x_1, undefined);
|
|
817
861
|
acc.tail = t;
|
|
818
862
|
return t;
|
|
819
863
|
}
|
|
@@ -821,45 +865,45 @@ export function filter(f, xs) {
|
|
|
821
865
|
return acc;
|
|
822
866
|
}
|
|
823
867
|
}, root, xs);
|
|
824
|
-
const t_2 =
|
|
868
|
+
const t_2 = empty();
|
|
825
869
|
node.tail = t_2;
|
|
826
870
|
return FSharpList__get_Tail(root);
|
|
827
871
|
}
|
|
828
872
|
export function partition(f, xs) {
|
|
829
|
-
const matchValue =
|
|
830
|
-
const root2 =
|
|
873
|
+
const matchValue = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
874
|
+
const root2 = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
831
875
|
const root1 = matchValue;
|
|
832
|
-
const patternInput_1 = fold((tupledArg,
|
|
876
|
+
const patternInput_1 = fold((tupledArg, x_2) => {
|
|
833
877
|
let t = undefined, t_2 = undefined;
|
|
834
878
|
const lacc = tupledArg[0];
|
|
835
879
|
const racc = tupledArg[1];
|
|
836
|
-
if (f(
|
|
837
|
-
return [(t = (
|
|
880
|
+
if (f(x_2)) {
|
|
881
|
+
return [(t = FSharpList_$ctor_Z23DD7291(x_2, undefined), (lacc.tail = t, t)), racc];
|
|
838
882
|
}
|
|
839
883
|
else {
|
|
840
|
-
return [lacc, (t_2 = (
|
|
884
|
+
return [lacc, (t_2 = FSharpList_$ctor_Z23DD7291(x_2, undefined), (racc.tail = t_2, t_2))];
|
|
841
885
|
}
|
|
842
886
|
}, [root1, root2], xs);
|
|
843
|
-
const t_4 =
|
|
887
|
+
const t_4 = empty();
|
|
844
888
|
patternInput_1[0].tail = t_4;
|
|
845
|
-
const t_5 =
|
|
889
|
+
const t_5 = empty();
|
|
846
890
|
patternInput_1[1].tail = t_5;
|
|
847
891
|
return [FSharpList__get_Tail(root1), FSharpList__get_Tail(root2)];
|
|
848
892
|
}
|
|
849
893
|
export function choose(f, xs) {
|
|
850
|
-
const root =
|
|
851
|
-
const node = fold((acc,
|
|
852
|
-
const matchValue = f(
|
|
894
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
895
|
+
const node = fold((acc, x_1) => {
|
|
896
|
+
const matchValue = f(x_1);
|
|
853
897
|
if (matchValue == null) {
|
|
854
898
|
return acc;
|
|
855
899
|
}
|
|
856
900
|
else {
|
|
857
|
-
const t =
|
|
901
|
+
const t = FSharpList_$ctor_Z23DD7291(value_1(matchValue), undefined);
|
|
858
902
|
acc.tail = t;
|
|
859
903
|
return t;
|
|
860
904
|
}
|
|
861
905
|
}, root, xs);
|
|
862
|
-
const t_2 =
|
|
906
|
+
const t_2 = empty();
|
|
863
907
|
node.tail = t_2;
|
|
864
908
|
return FSharpList__get_Tail(root);
|
|
865
909
|
}
|
|
@@ -867,14 +911,17 @@ export function contains(value, xs, eq) {
|
|
|
867
911
|
return tryFindIndex((v) => eq.Equals(value, v), xs) != null;
|
|
868
912
|
}
|
|
869
913
|
export function initialize(n, f) {
|
|
870
|
-
|
|
914
|
+
if (n < 0) {
|
|
915
|
+
throw Operators_InvalidArg("count", SR_inputMustBeNonNegative);
|
|
916
|
+
}
|
|
917
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
871
918
|
let node = root;
|
|
872
919
|
for (let i = 0; i <= (n - 1); i++) {
|
|
873
920
|
let xs = undefined, t = undefined;
|
|
874
|
-
node = ((xs = node, (t = (
|
|
921
|
+
node = ((xs = node, (t = FSharpList_$ctor_Z23DD7291(f(i), undefined), (xs.tail = t, t))));
|
|
875
922
|
}
|
|
876
923
|
const xs_2 = node;
|
|
877
|
-
const t_2 =
|
|
924
|
+
const t_2 = empty();
|
|
878
925
|
xs_2.tail = t_2;
|
|
879
926
|
return FSharpList__get_Tail(root);
|
|
880
927
|
}
|
|
@@ -883,7 +930,7 @@ export function replicate(n, x) {
|
|
|
883
930
|
}
|
|
884
931
|
export function reduce(f, xs) {
|
|
885
932
|
if (FSharpList__get_IsEmpty(xs)) {
|
|
886
|
-
throw
|
|
933
|
+
throw Operators_InvalidArg("list", SR_inputWasEmpty);
|
|
887
934
|
}
|
|
888
935
|
else {
|
|
889
936
|
return fold(f, head(xs), tail(xs));
|
|
@@ -891,7 +938,7 @@ export function reduce(f, xs) {
|
|
|
891
938
|
}
|
|
892
939
|
export function reduceBack(f, xs) {
|
|
893
940
|
if (FSharpList__get_IsEmpty(xs)) {
|
|
894
|
-
throw
|
|
941
|
+
throw Operators_InvalidArg("list", SR_inputWasEmpty);
|
|
895
942
|
}
|
|
896
943
|
else {
|
|
897
944
|
return foldBack(f, tail(xs), head(xs));
|
|
@@ -900,8 +947,33 @@ export function reduceBack(f, xs) {
|
|
|
900
947
|
export function forAll(f, xs) {
|
|
901
948
|
return fold((acc, x) => (acc && f(x)), true, xs);
|
|
902
949
|
}
|
|
903
|
-
export function forAll2(
|
|
904
|
-
|
|
950
|
+
export function forAll2(f_mut, xs_mut, ys_mut) {
|
|
951
|
+
forAll2: while (true) {
|
|
952
|
+
const f = f_mut, xs = xs_mut, ys = ys_mut;
|
|
953
|
+
const matchValue = FSharpList__get_IsEmpty(xs);
|
|
954
|
+
const matchValue_1 = FSharpList__get_IsEmpty(ys);
|
|
955
|
+
if (matchValue) {
|
|
956
|
+
if (matchValue_1) {
|
|
957
|
+
return true;
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
return differentLengths("list1");
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
else if (matchValue_1) {
|
|
964
|
+
return differentLengths("list2");
|
|
965
|
+
}
|
|
966
|
+
else if (f(FSharpList__get_Head(xs), FSharpList__get_Head(ys))) {
|
|
967
|
+
f_mut = f;
|
|
968
|
+
xs_mut = FSharpList__get_Tail(xs);
|
|
969
|
+
ys_mut = FSharpList__get_Tail(ys);
|
|
970
|
+
continue forAll2;
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
return false;
|
|
974
|
+
}
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
905
977
|
}
|
|
906
978
|
export function exists(f, xs) {
|
|
907
979
|
return tryFindIndex(f, xs) != null;
|
|
@@ -940,16 +1012,16 @@ export function exists2(f_mut, xs_mut, ys_mut) {
|
|
|
940
1012
|
continue exists2;
|
|
941
1013
|
}
|
|
942
1014
|
default:
|
|
943
|
-
|
|
1015
|
+
return differentLengths("list2");
|
|
944
1016
|
}
|
|
945
1017
|
break;
|
|
946
1018
|
}
|
|
947
1019
|
}
|
|
948
1020
|
export function unzip(xs) {
|
|
949
|
-
return foldBack((tupledArg, tupledArg_1) => [
|
|
1021
|
+
return foldBack((tupledArg, tupledArg_1) => [FSharpList_$ctor_Z23DD7291(tupledArg[0], tupledArg_1[0]), FSharpList_$ctor_Z23DD7291(tupledArg[1], tupledArg_1[1])], xs, [empty(), empty()]);
|
|
950
1022
|
}
|
|
951
1023
|
export function unzip3(xs) {
|
|
952
|
-
return foldBack((tupledArg, tupledArg_1) => [
|
|
1024
|
+
return foldBack((tupledArg, tupledArg_1) => [FSharpList_$ctor_Z23DD7291(tupledArg[0], tupledArg_1[0]), FSharpList_$ctor_Z23DD7291(tupledArg[1], tupledArg_1[1]), FSharpList_$ctor_Z23DD7291(tupledArg[2], tupledArg_1[2])], xs, [empty(), empty(), empty()]);
|
|
953
1025
|
}
|
|
954
1026
|
export function zip(xs, ys) {
|
|
955
1027
|
return map2((x, y) => [x, y], xs, ys);
|
|
@@ -993,6 +1065,9 @@ export function min(xs, comparer) {
|
|
|
993
1065
|
return reduce((x, y) => ((comparer.Compare(y, x) > 0) ? x : y), xs);
|
|
994
1066
|
}
|
|
995
1067
|
export function average(xs, averager) {
|
|
1068
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
1069
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
1070
|
+
}
|
|
996
1071
|
let count = 0;
|
|
997
1072
|
const total = fold((acc, x) => {
|
|
998
1073
|
count = ((count + 1) | 0);
|
|
@@ -1001,6 +1076,9 @@ export function average(xs, averager) {
|
|
|
1001
1076
|
return averager.DivideByInt(total, count);
|
|
1002
1077
|
}
|
|
1003
1078
|
export function averageBy(f, xs, averager) {
|
|
1079
|
+
if (FSharpList__get_IsEmpty(xs)) {
|
|
1080
|
+
throw Operators_InvalidArg("source", SR_inputSequenceEmpty);
|
|
1081
|
+
}
|
|
1004
1082
|
let count = 0;
|
|
1005
1083
|
const total = fold((acc, x) => {
|
|
1006
1084
|
count = ((count + 1) | 0);
|
|
@@ -1015,16 +1093,16 @@ export function chunkBySize(chunkSize, xs) {
|
|
|
1015
1093
|
return ofArray(map_1(ofArray, chunkBySize_1(chunkSize, toArray(xs))));
|
|
1016
1094
|
}
|
|
1017
1095
|
export function allPairs(xs, ys) {
|
|
1018
|
-
const root =
|
|
1096
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
1019
1097
|
let node = root;
|
|
1020
|
-
iterate((
|
|
1098
|
+
iterate((x_1) => {
|
|
1021
1099
|
iterate((y) => {
|
|
1022
1100
|
let xs_1 = undefined, t = undefined;
|
|
1023
|
-
node = ((xs_1 = node, (t = (
|
|
1101
|
+
node = ((xs_1 = node, (t = FSharpList_$ctor_Z23DD7291([x_1, y], undefined), (xs_1.tail = t, t))));
|
|
1024
1102
|
}, ys);
|
|
1025
1103
|
}, xs);
|
|
1026
1104
|
const xs_3 = node;
|
|
1027
|
-
const t_2 =
|
|
1105
|
+
const t_2 = empty();
|
|
1028
1106
|
xs_3.tail = t_2;
|
|
1029
1107
|
return FSharpList__get_Tail(root);
|
|
1030
1108
|
}
|
|
@@ -1035,7 +1113,7 @@ export function skip(count_mut, xs_mut) {
|
|
|
1035
1113
|
return xs;
|
|
1036
1114
|
}
|
|
1037
1115
|
else if (FSharpList__get_IsEmpty(xs)) {
|
|
1038
|
-
throw
|
|
1116
|
+
throw ArgumentOutOfRangeException_$ctor_Z384F8060("count", "The index is outside the legal range.");
|
|
1039
1117
|
}
|
|
1040
1118
|
else {
|
|
1041
1119
|
count_mut = (count - 1);
|
|
@@ -1064,7 +1142,7 @@ export function skipWhile(predicate_mut, xs_mut) {
|
|
|
1064
1142
|
}
|
|
1065
1143
|
export function take(count, xs) {
|
|
1066
1144
|
if (count < 0) {
|
|
1067
|
-
throw
|
|
1145
|
+
throw Operators_InvalidArg("count", SR_inputMustBeNonNegative);
|
|
1068
1146
|
}
|
|
1069
1147
|
const loop = (i_mut, acc_mut, xs_1_mut) => {
|
|
1070
1148
|
loop: while (true) {
|
|
@@ -1074,20 +1152,20 @@ export function take(count, xs) {
|
|
|
1074
1152
|
return acc;
|
|
1075
1153
|
}
|
|
1076
1154
|
else if (FSharpList__get_IsEmpty(xs_1)) {
|
|
1077
|
-
throw
|
|
1155
|
+
throw Operators_InvalidOp(SR_notEnoughElements);
|
|
1078
1156
|
}
|
|
1079
1157
|
else {
|
|
1080
1158
|
i_mut = (i - 1);
|
|
1081
|
-
acc_mut = ((t = (
|
|
1159
|
+
acc_mut = ((t = FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(xs_1), undefined), (acc.tail = t, t)));
|
|
1082
1160
|
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
1083
1161
|
continue loop;
|
|
1084
1162
|
}
|
|
1085
1163
|
break;
|
|
1086
1164
|
}
|
|
1087
1165
|
};
|
|
1088
|
-
const root =
|
|
1166
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
1089
1167
|
const node = loop(count, root, xs);
|
|
1090
|
-
const t_2 =
|
|
1168
|
+
const t_2 = empty();
|
|
1091
1169
|
node.tail = t_2;
|
|
1092
1170
|
return FSharpList__get_Tail(root);
|
|
1093
1171
|
}
|
|
@@ -1103,16 +1181,16 @@ export function takeWhile(predicate, xs) {
|
|
|
1103
1181
|
return acc;
|
|
1104
1182
|
}
|
|
1105
1183
|
else {
|
|
1106
|
-
acc_mut = ((t = (
|
|
1184
|
+
acc_mut = ((t = FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(xs_1), undefined), (acc.tail = t, t)));
|
|
1107
1185
|
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
1108
1186
|
continue loop;
|
|
1109
1187
|
}
|
|
1110
1188
|
break;
|
|
1111
1189
|
}
|
|
1112
1190
|
};
|
|
1113
|
-
const root =
|
|
1191
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
1114
1192
|
const node = loop(root, xs);
|
|
1115
|
-
const t_2 =
|
|
1193
|
+
const t_2 = empty();
|
|
1116
1194
|
node.tail = t_2;
|
|
1117
1195
|
return FSharpList__get_Tail(root);
|
|
1118
1196
|
}
|
|
@@ -1129,16 +1207,16 @@ export function truncate(count, xs) {
|
|
|
1129
1207
|
}
|
|
1130
1208
|
else {
|
|
1131
1209
|
i_mut = (i - 1);
|
|
1132
|
-
acc_mut = ((t = (
|
|
1210
|
+
acc_mut = ((t = FSharpList_$ctor_Z23DD7291(FSharpList__get_Head(xs_1), undefined), (acc.tail = t, t)));
|
|
1133
1211
|
xs_1_mut = FSharpList__get_Tail(xs_1);
|
|
1134
1212
|
continue loop;
|
|
1135
1213
|
}
|
|
1136
1214
|
break;
|
|
1137
1215
|
}
|
|
1138
1216
|
};
|
|
1139
|
-
const root =
|
|
1217
|
+
const root = FSharpList_$ctor_Z23DD7291(defaultOf(), undefined);
|
|
1140
1218
|
const node = loop(count, root, xs);
|
|
1141
|
-
const t_2 =
|
|
1219
|
+
const t_2 = empty();
|
|
1142
1220
|
node.tail = t_2;
|
|
1143
1221
|
return FSharpList__get_Tail(root);
|
|
1144
1222
|
}
|
|
@@ -1151,7 +1229,7 @@ export function getSlice(startIndex, endIndex, xs) {
|
|
|
1151
1229
|
const index_1 = defaultArg(endIndex, len - 1) | 0;
|
|
1152
1230
|
endIndex_1 = ((index_1 >= len) ? (len - 1) : index_1);
|
|
1153
1231
|
if (endIndex_1 < startIndex_1) {
|
|
1154
|
-
return
|
|
1232
|
+
return empty();
|
|
1155
1233
|
}
|
|
1156
1234
|
else {
|
|
1157
1235
|
return take((endIndex_1 - startIndex_1) + 1, skip(startIndex_1, xs));
|
|
@@ -1159,22 +1237,22 @@ export function getSlice(startIndex, endIndex, xs) {
|
|
|
1159
1237
|
}
|
|
1160
1238
|
export function splitAt(index, xs) {
|
|
1161
1239
|
if (index < 0) {
|
|
1162
|
-
throw
|
|
1240
|
+
throw Operators_InvalidArg("index", SR_inputMustBeNonNegative);
|
|
1163
1241
|
}
|
|
1164
1242
|
if (index > FSharpList__get_Length(xs)) {
|
|
1165
|
-
throw
|
|
1243
|
+
throw Operators_InvalidOp(SR_notEnoughElements);
|
|
1166
1244
|
}
|
|
1167
1245
|
return [take(index, xs), skip(index, xs)];
|
|
1168
1246
|
}
|
|
1169
1247
|
export function exactlyOne(xs) {
|
|
1170
1248
|
if (FSharpList__get_IsEmpty(xs)) {
|
|
1171
|
-
throw
|
|
1249
|
+
throw Operators_InvalidArg("list", SR_inputSequenceEmpty);
|
|
1172
1250
|
}
|
|
1173
1251
|
else if (FSharpList__get_IsEmpty(FSharpList__get_Tail(xs))) {
|
|
1174
1252
|
return FSharpList__get_Head(xs);
|
|
1175
1253
|
}
|
|
1176
1254
|
else {
|
|
1177
|
-
throw
|
|
1255
|
+
throw Operators_InvalidArg("list", SR_inputSequenceTooLong);
|
|
1178
1256
|
}
|
|
1179
1257
|
}
|
|
1180
1258
|
export function tryExactlyOne(xs) {
|
|
@@ -1207,14 +1285,14 @@ export function insertAt(index, y, xs) {
|
|
|
1207
1285
|
i = ((i + 1) | 0);
|
|
1208
1286
|
if (i === index) {
|
|
1209
1287
|
isDone = true;
|
|
1210
|
-
return
|
|
1288
|
+
return FSharpList_$ctor_Z23DD7291(x, FSharpList_$ctor_Z23DD7291(y, acc));
|
|
1211
1289
|
}
|
|
1212
1290
|
else {
|
|
1213
|
-
return
|
|
1291
|
+
return FSharpList_$ctor_Z23DD7291(x, acc);
|
|
1214
1292
|
}
|
|
1215
|
-
},
|
|
1216
|
-
return reverse(isDone ? result : (((i + 1) === index) ?
|
|
1217
|
-
throw
|
|
1293
|
+
}, empty(), xs);
|
|
1294
|
+
return reverse(isDone ? result : (((i + 1) === index) ? FSharpList_$ctor_Z23DD7291(y, result) : (() => {
|
|
1295
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1218
1296
|
})()));
|
|
1219
1297
|
}
|
|
1220
1298
|
export function insertManyAt(index, ys, xs) {
|
|
@@ -1225,14 +1303,14 @@ export function insertManyAt(index, ys, xs) {
|
|
|
1225
1303
|
i = ((i + 1) | 0);
|
|
1226
1304
|
if (i === index) {
|
|
1227
1305
|
isDone = true;
|
|
1228
|
-
return
|
|
1306
|
+
return FSharpList_$ctor_Z23DD7291(x, append(ys_1, acc));
|
|
1229
1307
|
}
|
|
1230
1308
|
else {
|
|
1231
|
-
return
|
|
1309
|
+
return FSharpList_$ctor_Z23DD7291(x, acc);
|
|
1232
1310
|
}
|
|
1233
|
-
},
|
|
1311
|
+
}, empty(), xs);
|
|
1234
1312
|
return reverse(isDone ? result : (((i + 1) === index) ? append(ys_1, result) : (() => {
|
|
1235
|
-
throw
|
|
1313
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1236
1314
|
})()));
|
|
1237
1315
|
}
|
|
1238
1316
|
export function removeAt(index, xs) {
|
|
@@ -1249,35 +1327,27 @@ export function removeAt(index, xs) {
|
|
|
1249
1327
|
}
|
|
1250
1328
|
}, xs);
|
|
1251
1329
|
if (!isDone) {
|
|
1252
|
-
throw
|
|
1330
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1253
1331
|
}
|
|
1254
1332
|
return ys;
|
|
1255
1333
|
}
|
|
1256
1334
|
export function removeManyAt(index, count, xs) {
|
|
1335
|
+
if (index < 0) {
|
|
1336
|
+
throw Operators_InvalidArg("index", "index must be within bounds of the list");
|
|
1337
|
+
}
|
|
1338
|
+
const endIndex = (index + count) | 0;
|
|
1257
1339
|
let i = -1;
|
|
1258
|
-
let status = -1;
|
|
1259
1340
|
const ys = filter((_arg) => {
|
|
1260
1341
|
i = ((i + 1) | 0);
|
|
1261
|
-
if (i
|
|
1262
|
-
|
|
1263
|
-
return false;
|
|
1264
|
-
}
|
|
1265
|
-
else if (i > index) {
|
|
1266
|
-
if (i < (index + count)) {
|
|
1267
|
-
return false;
|
|
1268
|
-
}
|
|
1269
|
-
else {
|
|
1270
|
-
status = 1;
|
|
1271
|
-
return true;
|
|
1272
|
-
}
|
|
1342
|
+
if (i < index) {
|
|
1343
|
+
return true;
|
|
1273
1344
|
}
|
|
1274
1345
|
else {
|
|
1275
|
-
return
|
|
1346
|
+
return i >= endIndex;
|
|
1276
1347
|
}
|
|
1277
1348
|
}, xs);
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
throw new Exception(SR_indexOutOfBounds + ((" (Parameter \'" + ((status_1 < 0) ? "index" : "count")) + "\')"));
|
|
1349
|
+
if (endIndex > (i + 1)) {
|
|
1350
|
+
throw Operators_InvalidArg("index", "index must be within bounds of the list");
|
|
1281
1351
|
}
|
|
1282
1352
|
return ys;
|
|
1283
1353
|
}
|
|
@@ -1293,7 +1363,7 @@ export function updateAt(index, y, xs) {
|
|
|
1293
1363
|
}
|
|
1294
1364
|
}, xs);
|
|
1295
1365
|
if (!isDone) {
|
|
1296
|
-
throw
|
|
1366
|
+
throw Operators_InvalidArg("index", SR_indexOutOfBounds);
|
|
1297
1367
|
}
|
|
1298
1368
|
return ys;
|
|
1299
1369
|
}
|