compostjs 0.0.8 → 0.0.12
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/README.md +4 -4
- 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 +6 -5
- package/.claude/settings.local.json +0 -11
- 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,1378 @@
|
|
|
1
|
+
import { clear, defaultOf, equals, isDisposable, isArrayLike, toIterator, disposeSafe, getEnumerator } from "./Util.js";
|
|
2
|
+
import { toString } from "./Types.js";
|
|
3
|
+
import { class_type } from "./Reflection.js";
|
|
4
|
+
import { some, value as value_1 } from "./Option.js";
|
|
5
|
+
import { Operators_Lock, Operators_NullArg } from "./FSharp.Core.js";
|
|
6
|
+
import { chunkBySize as chunkBySize_1, permute as permute_1, transpose as transpose_1, map as map_1, windowed as windowed_1, splitInto as splitInto_1, pairwise as pairwise_1, scanBack as scanBack_1, reverse as reverse_1, mapFoldBack as mapFoldBack_1, mapFold as mapFold_1, tryItem as tryItem_1, tryHead as tryHead_1, foldBack2 as foldBack2_1, foldBack as foldBack_1, tryFindIndexBack as tryFindIndexBack_1, tryFindBack as tryFindBack_1, singleton as singleton_1 } from "./Array.js";
|
|
7
|
+
import { length as length_1, tryItem as tryItem_2, isEmpty as isEmpty_1, tryHead as tryHead_2, ofSeq as ofSeq_1, ofArray as ofArray_1, toArray as toArray_1, FSharpList } from "./List.js";
|
|
8
|
+
import { SR_indexOutOfBounds } from "./Global.js";
|
|
9
|
+
export const SR_enumerationAlreadyFinished = "Enumeration already finished.";
|
|
10
|
+
export const SR_enumerationNotStarted = "Enumeration has not started. Call MoveNext.";
|
|
11
|
+
export const SR_inputSequenceEmpty = "The input sequence was empty.";
|
|
12
|
+
export const SR_inputSequenceTooLong = "The input sequence contains more than one element.";
|
|
13
|
+
export const SR_keyNotFoundAlt = "An index satisfying the predicate was not found in the collection.";
|
|
14
|
+
export const SR_notEnoughElements = "The input sequence has an insufficient number of elements.";
|
|
15
|
+
export const SR_resetNotSupported = "Reset is not supported on this enumerator.";
|
|
16
|
+
export function Enumerator_noReset() {
|
|
17
|
+
throw new Error(SR_resetNotSupported);
|
|
18
|
+
}
|
|
19
|
+
export function Enumerator_notStarted() {
|
|
20
|
+
throw new Error(SR_enumerationNotStarted);
|
|
21
|
+
}
|
|
22
|
+
export function Enumerator_alreadyFinished() {
|
|
23
|
+
throw new Error(SR_enumerationAlreadyFinished);
|
|
24
|
+
}
|
|
25
|
+
export class Enumerator_Seq {
|
|
26
|
+
constructor(f) {
|
|
27
|
+
this.f = f;
|
|
28
|
+
}
|
|
29
|
+
toString() {
|
|
30
|
+
const xs = this;
|
|
31
|
+
let i = 0;
|
|
32
|
+
let str = "seq [";
|
|
33
|
+
const e = getEnumerator(xs);
|
|
34
|
+
try {
|
|
35
|
+
while ((i < 4) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
36
|
+
if (i > 0) {
|
|
37
|
+
str = (str + "; ");
|
|
38
|
+
}
|
|
39
|
+
str = (str + toString(e["System.Collections.Generic.IEnumerator`1.get_Current"]()));
|
|
40
|
+
i = ((i + 1) | 0);
|
|
41
|
+
}
|
|
42
|
+
if (i === 4) {
|
|
43
|
+
str = (str + "; ...");
|
|
44
|
+
}
|
|
45
|
+
return str + "]";
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
disposeSafe(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
GetEnumerator() {
|
|
52
|
+
const x = this;
|
|
53
|
+
return x.f();
|
|
54
|
+
}
|
|
55
|
+
[Symbol.iterator]() {
|
|
56
|
+
return toIterator(getEnumerator(this));
|
|
57
|
+
}
|
|
58
|
+
"System.Collections.IEnumerable.GetEnumerator"() {
|
|
59
|
+
const x = this;
|
|
60
|
+
return x.f();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function Enumerator_Seq_$reflection(gen0) {
|
|
64
|
+
return class_type("SeqModule.Enumerator.Seq", [gen0], Enumerator_Seq);
|
|
65
|
+
}
|
|
66
|
+
export function Enumerator_Seq_$ctor_673A07F2(f) {
|
|
67
|
+
return new Enumerator_Seq(f);
|
|
68
|
+
}
|
|
69
|
+
export class Enumerator_FromFunctions$1 {
|
|
70
|
+
constructor(current, next, dispose) {
|
|
71
|
+
this.current = current;
|
|
72
|
+
this.next = next;
|
|
73
|
+
this.dispose = dispose;
|
|
74
|
+
}
|
|
75
|
+
"System.Collections.Generic.IEnumerator`1.get_Current"() {
|
|
76
|
+
const _ = this;
|
|
77
|
+
return _.current();
|
|
78
|
+
}
|
|
79
|
+
"System.Collections.IEnumerator.get_Current"() {
|
|
80
|
+
const _ = this;
|
|
81
|
+
return _.current();
|
|
82
|
+
}
|
|
83
|
+
"System.Collections.IEnumerator.MoveNext"() {
|
|
84
|
+
const _ = this;
|
|
85
|
+
return _.next();
|
|
86
|
+
}
|
|
87
|
+
"System.Collections.IEnumerator.Reset"() {
|
|
88
|
+
Enumerator_noReset();
|
|
89
|
+
}
|
|
90
|
+
Dispose() {
|
|
91
|
+
const _ = this;
|
|
92
|
+
_.dispose();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function Enumerator_FromFunctions$1_$reflection(gen0) {
|
|
96
|
+
return class_type("SeqModule.Enumerator.FromFunctions`1", [gen0], Enumerator_FromFunctions$1);
|
|
97
|
+
}
|
|
98
|
+
export function Enumerator_FromFunctions$1_$ctor_58C54629(current, next, dispose) {
|
|
99
|
+
return new Enumerator_FromFunctions$1(current, next, dispose);
|
|
100
|
+
}
|
|
101
|
+
export function Enumerator_cast(e) {
|
|
102
|
+
return Enumerator_FromFunctions$1_$ctor_58C54629(() => e["System.Collections.Generic.IEnumerator`1.get_Current"](), () => e["System.Collections.IEnumerator.MoveNext"](), () => {
|
|
103
|
+
disposeSafe(e);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function Enumerator_concat(sources) {
|
|
107
|
+
let outerOpt = undefined;
|
|
108
|
+
let innerOpt = undefined;
|
|
109
|
+
let started = false;
|
|
110
|
+
let finished = false;
|
|
111
|
+
let curr = undefined;
|
|
112
|
+
const finish = () => {
|
|
113
|
+
finished = true;
|
|
114
|
+
if (innerOpt != null) {
|
|
115
|
+
const inner = value_1(innerOpt);
|
|
116
|
+
try {
|
|
117
|
+
disposeSafe(inner);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
innerOpt = undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (outerOpt != null) {
|
|
124
|
+
const outer = value_1(outerOpt);
|
|
125
|
+
try {
|
|
126
|
+
disposeSafe(outer);
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
outerOpt = undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return Enumerator_FromFunctions$1_$ctor_58C54629(() => {
|
|
134
|
+
if (!started) {
|
|
135
|
+
Enumerator_notStarted();
|
|
136
|
+
}
|
|
137
|
+
else if (finished) {
|
|
138
|
+
Enumerator_alreadyFinished();
|
|
139
|
+
}
|
|
140
|
+
if (curr != null) {
|
|
141
|
+
return value_1(curr);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return Enumerator_alreadyFinished();
|
|
145
|
+
}
|
|
146
|
+
}, () => {
|
|
147
|
+
let copyOfStruct;
|
|
148
|
+
if (!started) {
|
|
149
|
+
started = true;
|
|
150
|
+
}
|
|
151
|
+
if (finished) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
let res = undefined;
|
|
156
|
+
while (res == null) {
|
|
157
|
+
const outerOpt_1 = outerOpt;
|
|
158
|
+
const innerOpt_1 = innerOpt;
|
|
159
|
+
if (outerOpt_1 != null) {
|
|
160
|
+
if (innerOpt_1 != null) {
|
|
161
|
+
const inner_1 = value_1(innerOpt_1);
|
|
162
|
+
if (inner_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
163
|
+
curr = some(inner_1["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
164
|
+
res = true;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
try {
|
|
168
|
+
disposeSafe(inner_1);
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
innerOpt = undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const outer_1 = value_1(outerOpt_1);
|
|
177
|
+
if (outer_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
178
|
+
const ie = outer_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
179
|
+
innerOpt = ((copyOfStruct = ie, getEnumerator(copyOfStruct)));
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
finish();
|
|
183
|
+
res = false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
outerOpt = getEnumerator(sources);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return value_1(res);
|
|
192
|
+
}
|
|
193
|
+
}, () => {
|
|
194
|
+
if (!finished) {
|
|
195
|
+
finish();
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
export function Enumerator_enumerateThenFinally(f, e) {
|
|
200
|
+
return Enumerator_FromFunctions$1_$ctor_58C54629(() => e["System.Collections.Generic.IEnumerator`1.get_Current"](), () => e["System.Collections.IEnumerator.MoveNext"](), () => {
|
|
201
|
+
try {
|
|
202
|
+
disposeSafe(e);
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
f();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
export function Enumerator_generateWhileSome(openf, compute, closef) {
|
|
210
|
+
let started = false;
|
|
211
|
+
let curr = undefined;
|
|
212
|
+
let state = some(openf());
|
|
213
|
+
const dispose = () => {
|
|
214
|
+
if (state != null) {
|
|
215
|
+
const x_1 = value_1(state);
|
|
216
|
+
try {
|
|
217
|
+
closef(x_1);
|
|
218
|
+
}
|
|
219
|
+
finally {
|
|
220
|
+
state = undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const finish = () => {
|
|
225
|
+
try {
|
|
226
|
+
dispose();
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
curr = undefined;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
return Enumerator_FromFunctions$1_$ctor_58C54629(() => {
|
|
233
|
+
if (!started) {
|
|
234
|
+
Enumerator_notStarted();
|
|
235
|
+
}
|
|
236
|
+
if (curr != null) {
|
|
237
|
+
return value_1(curr);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return Enumerator_alreadyFinished();
|
|
241
|
+
}
|
|
242
|
+
}, () => {
|
|
243
|
+
if (!started) {
|
|
244
|
+
started = true;
|
|
245
|
+
}
|
|
246
|
+
if (state != null) {
|
|
247
|
+
const s = value_1(state);
|
|
248
|
+
let matchValue_1;
|
|
249
|
+
try {
|
|
250
|
+
matchValue_1 = compute(s);
|
|
251
|
+
}
|
|
252
|
+
catch (matchValue) {
|
|
253
|
+
finish();
|
|
254
|
+
throw matchValue;
|
|
255
|
+
}
|
|
256
|
+
if (matchValue_1 != null) {
|
|
257
|
+
curr = matchValue_1;
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
finish();
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}, dispose);
|
|
269
|
+
}
|
|
270
|
+
export function Enumerator_unfold(f, state) {
|
|
271
|
+
let curr = undefined;
|
|
272
|
+
let acc = state;
|
|
273
|
+
return Enumerator_FromFunctions$1_$ctor_58C54629(() => {
|
|
274
|
+
if (curr != null) {
|
|
275
|
+
const x = value_1(curr)[0];
|
|
276
|
+
const st = value_1(curr)[1];
|
|
277
|
+
return x;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
return Enumerator_notStarted();
|
|
281
|
+
}
|
|
282
|
+
}, () => {
|
|
283
|
+
curr = f(acc);
|
|
284
|
+
if (curr != null) {
|
|
285
|
+
const x_1 = value_1(curr)[0];
|
|
286
|
+
const st_1 = value_1(curr)[1];
|
|
287
|
+
acc = st_1;
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}, () => {
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
export function indexNotFound() {
|
|
297
|
+
throw new Error(SR_keyNotFoundAlt);
|
|
298
|
+
}
|
|
299
|
+
export function checkNonNull(argName, arg) {
|
|
300
|
+
if (arg == null) {
|
|
301
|
+
Operators_NullArg(argName);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
export function mkSeq(f) {
|
|
305
|
+
return Enumerator_Seq_$ctor_673A07F2(f);
|
|
306
|
+
}
|
|
307
|
+
export function ofSeq(xs) {
|
|
308
|
+
checkNonNull("source", xs);
|
|
309
|
+
return getEnumerator(xs);
|
|
310
|
+
}
|
|
311
|
+
export function delay(generator) {
|
|
312
|
+
return mkSeq(() => getEnumerator(generator()));
|
|
313
|
+
}
|
|
314
|
+
export function concat(sources) {
|
|
315
|
+
return mkSeq(() => Enumerator_concat(sources));
|
|
316
|
+
}
|
|
317
|
+
export function unfold(generator, state) {
|
|
318
|
+
return mkSeq(() => Enumerator_unfold(generator, state));
|
|
319
|
+
}
|
|
320
|
+
export function empty() {
|
|
321
|
+
return delay(() => (new Array(0)));
|
|
322
|
+
}
|
|
323
|
+
export function singleton(x) {
|
|
324
|
+
return delay(() => singleton_1(x));
|
|
325
|
+
}
|
|
326
|
+
export function ofArray(arr) {
|
|
327
|
+
return arr;
|
|
328
|
+
}
|
|
329
|
+
export function toArray(xs) {
|
|
330
|
+
if (xs instanceof FSharpList) {
|
|
331
|
+
const a = xs;
|
|
332
|
+
return toArray_1(a);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
return Array.from(xs);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export function ofList(xs) {
|
|
339
|
+
return xs;
|
|
340
|
+
}
|
|
341
|
+
export function toList(xs) {
|
|
342
|
+
if (isArrayLike(xs)) {
|
|
343
|
+
return ofArray_1(xs);
|
|
344
|
+
}
|
|
345
|
+
else if (xs instanceof FSharpList) {
|
|
346
|
+
return xs;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
return ofSeq_1(xs);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
export function generate(create, compute, dispose) {
|
|
353
|
+
return mkSeq(() => Enumerator_generateWhileSome(create, compute, dispose));
|
|
354
|
+
}
|
|
355
|
+
export function generateIndexed(create, compute, dispose) {
|
|
356
|
+
return mkSeq(() => {
|
|
357
|
+
let i = -1;
|
|
358
|
+
return Enumerator_generateWhileSome(create, (x) => {
|
|
359
|
+
i = ((i + 1) | 0);
|
|
360
|
+
return compute(i, x);
|
|
361
|
+
}, dispose);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
export function append(xs, ys) {
|
|
365
|
+
return concat([xs, ys]);
|
|
366
|
+
}
|
|
367
|
+
export function cast(xs) {
|
|
368
|
+
return mkSeq(() => {
|
|
369
|
+
checkNonNull("source", xs);
|
|
370
|
+
return Enumerator_cast(getEnumerator(xs));
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
export function choose(chooser, xs) {
|
|
374
|
+
return generate(() => ofSeq(xs), (e) => {
|
|
375
|
+
let curr = undefined;
|
|
376
|
+
while ((curr == null) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
377
|
+
curr = chooser(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
378
|
+
}
|
|
379
|
+
return curr;
|
|
380
|
+
}, (e_1) => {
|
|
381
|
+
disposeSafe(e_1);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
export function compareWith(comparer, xs, ys) {
|
|
385
|
+
const e1 = ofSeq(xs);
|
|
386
|
+
try {
|
|
387
|
+
const e2 = ofSeq(ys);
|
|
388
|
+
try {
|
|
389
|
+
let c = 0;
|
|
390
|
+
let b1 = e1["System.Collections.IEnumerator.MoveNext"]();
|
|
391
|
+
let b2 = e2["System.Collections.IEnumerator.MoveNext"]();
|
|
392
|
+
while (((c === 0) && b1) && b2) {
|
|
393
|
+
c = (comparer(e1["System.Collections.Generic.IEnumerator`1.get_Current"](), e2["System.Collections.Generic.IEnumerator`1.get_Current"]()) | 0);
|
|
394
|
+
if (c === 0) {
|
|
395
|
+
b1 = e1["System.Collections.IEnumerator.MoveNext"]();
|
|
396
|
+
b2 = e2["System.Collections.IEnumerator.MoveNext"]();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return ((c !== 0) ? c : (b1 ? 1 : (b2 ? -1 : 0))) | 0;
|
|
400
|
+
}
|
|
401
|
+
finally {
|
|
402
|
+
disposeSafe(e2);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
finally {
|
|
406
|
+
disposeSafe(e1);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
export function contains(value, xs, comparer) {
|
|
410
|
+
const e = ofSeq(xs);
|
|
411
|
+
try {
|
|
412
|
+
let found = false;
|
|
413
|
+
while (!found && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
414
|
+
found = comparer.Equals(value, e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
415
|
+
}
|
|
416
|
+
return found;
|
|
417
|
+
}
|
|
418
|
+
finally {
|
|
419
|
+
disposeSafe(e);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
export function enumerateFromFunctions(create, moveNext, current) {
|
|
423
|
+
return generate(create, (x) => (moveNext(x) ? some(current(x)) : undefined), (x_1) => {
|
|
424
|
+
const matchValue = x_1;
|
|
425
|
+
if (isDisposable(matchValue)) {
|
|
426
|
+
const id = matchValue;
|
|
427
|
+
disposeSafe(id);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
export function enumerateThenFinally(source, compensation) {
|
|
432
|
+
const compensation_1 = compensation;
|
|
433
|
+
return mkSeq(() => {
|
|
434
|
+
try {
|
|
435
|
+
return Enumerator_enumerateThenFinally(compensation_1, ofSeq(source));
|
|
436
|
+
}
|
|
437
|
+
catch (matchValue) {
|
|
438
|
+
compensation_1();
|
|
439
|
+
throw matchValue;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
export function enumerateUsing(resource, source) {
|
|
444
|
+
const compensation = () => {
|
|
445
|
+
if (equals(resource, defaultOf())) {
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
let copyOfStruct = resource;
|
|
449
|
+
disposeSafe(copyOfStruct);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
return mkSeq(() => {
|
|
453
|
+
try {
|
|
454
|
+
return Enumerator_enumerateThenFinally(compensation, ofSeq(source(resource)));
|
|
455
|
+
}
|
|
456
|
+
catch (matchValue_1) {
|
|
457
|
+
compensation();
|
|
458
|
+
throw matchValue_1;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
export function enumerateWhile(guard, xs) {
|
|
463
|
+
return concat(unfold((i) => (guard() ? [xs, i + 1] : undefined), 0));
|
|
464
|
+
}
|
|
465
|
+
export function filter(f, xs) {
|
|
466
|
+
return choose((x) => {
|
|
467
|
+
if (f(x)) {
|
|
468
|
+
return some(x);
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
return undefined;
|
|
472
|
+
}
|
|
473
|
+
}, xs);
|
|
474
|
+
}
|
|
475
|
+
export function exists(predicate, xs) {
|
|
476
|
+
const e = ofSeq(xs);
|
|
477
|
+
try {
|
|
478
|
+
let found = false;
|
|
479
|
+
while (!found && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
480
|
+
found = predicate(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
481
|
+
}
|
|
482
|
+
return found;
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
disposeSafe(e);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
export function exists2(predicate, xs, ys) {
|
|
489
|
+
const e1 = ofSeq(xs);
|
|
490
|
+
try {
|
|
491
|
+
const e2 = ofSeq(ys);
|
|
492
|
+
try {
|
|
493
|
+
let found = false;
|
|
494
|
+
while ((!found && e1["System.Collections.IEnumerator.MoveNext"]()) && e2["System.Collections.IEnumerator.MoveNext"]()) {
|
|
495
|
+
found = predicate(e1["System.Collections.Generic.IEnumerator`1.get_Current"](), e2["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
496
|
+
}
|
|
497
|
+
return found;
|
|
498
|
+
}
|
|
499
|
+
finally {
|
|
500
|
+
disposeSafe(e2);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
finally {
|
|
504
|
+
disposeSafe(e1);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
export function exactlyOne(xs) {
|
|
508
|
+
const e = ofSeq(xs);
|
|
509
|
+
try {
|
|
510
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
511
|
+
const v = e["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
512
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
513
|
+
throw new Error((SR_inputSequenceTooLong + "\\nParameter name: ") + "source");
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
return v;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
finally {
|
|
524
|
+
disposeSafe(e);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
export function tryExactlyOne(xs) {
|
|
528
|
+
const e = ofSeq(xs);
|
|
529
|
+
try {
|
|
530
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
531
|
+
const v = e["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
532
|
+
return e["System.Collections.IEnumerator.MoveNext"]() ? undefined : some(v);
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
finally {
|
|
539
|
+
disposeSafe(e);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
export function tryFind(predicate, xs) {
|
|
543
|
+
const e = ofSeq(xs);
|
|
544
|
+
try {
|
|
545
|
+
let res = undefined;
|
|
546
|
+
while ((res == null) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
547
|
+
const c = e["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
548
|
+
if (predicate(c)) {
|
|
549
|
+
res = some(c);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return res;
|
|
553
|
+
}
|
|
554
|
+
finally {
|
|
555
|
+
disposeSafe(e);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
export function find(predicate, xs) {
|
|
559
|
+
const matchValue = tryFind(predicate, xs);
|
|
560
|
+
if (matchValue == null) {
|
|
561
|
+
return indexNotFound();
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
return value_1(matchValue);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
export function tryFindBack(predicate, xs) {
|
|
568
|
+
return tryFindBack_1(predicate, toArray(xs));
|
|
569
|
+
}
|
|
570
|
+
export function findBack(predicate, xs) {
|
|
571
|
+
const matchValue = tryFindBack(predicate, xs);
|
|
572
|
+
if (matchValue == null) {
|
|
573
|
+
return indexNotFound();
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
return value_1(matchValue);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
export function tryFindIndex(predicate, xs) {
|
|
580
|
+
const e = ofSeq(xs);
|
|
581
|
+
try {
|
|
582
|
+
const loop = (i_mut) => {
|
|
583
|
+
loop: while (true) {
|
|
584
|
+
const i = i_mut;
|
|
585
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
586
|
+
if (predicate(e["System.Collections.Generic.IEnumerator`1.get_Current"]())) {
|
|
587
|
+
return i;
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
i_mut = (i + 1);
|
|
591
|
+
continue loop;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
return loop(0);
|
|
601
|
+
}
|
|
602
|
+
finally {
|
|
603
|
+
disposeSafe(e);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
export function findIndex(predicate, xs) {
|
|
607
|
+
const matchValue = tryFindIndex(predicate, xs);
|
|
608
|
+
if (matchValue == null) {
|
|
609
|
+
indexNotFound();
|
|
610
|
+
return -1;
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
return value_1(matchValue) | 0;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
export function tryFindIndexBack(predicate, xs) {
|
|
617
|
+
return tryFindIndexBack_1(predicate, toArray(xs));
|
|
618
|
+
}
|
|
619
|
+
export function findIndexBack(predicate, xs) {
|
|
620
|
+
const matchValue = tryFindIndexBack(predicate, xs);
|
|
621
|
+
if (matchValue == null) {
|
|
622
|
+
indexNotFound();
|
|
623
|
+
return -1;
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
return value_1(matchValue) | 0;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
export function fold(folder, state, xs) {
|
|
630
|
+
const e = ofSeq(xs);
|
|
631
|
+
try {
|
|
632
|
+
let acc = state;
|
|
633
|
+
while (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
634
|
+
acc = folder(acc, e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
635
|
+
}
|
|
636
|
+
return acc;
|
|
637
|
+
}
|
|
638
|
+
finally {
|
|
639
|
+
disposeSafe(e);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
export function foldBack(folder, xs, state) {
|
|
643
|
+
return foldBack_1(folder, toArray(xs), state);
|
|
644
|
+
}
|
|
645
|
+
export function fold2(folder, state, xs, ys) {
|
|
646
|
+
const e1 = ofSeq(xs);
|
|
647
|
+
try {
|
|
648
|
+
const e2 = ofSeq(ys);
|
|
649
|
+
try {
|
|
650
|
+
let acc = state;
|
|
651
|
+
while (e1["System.Collections.IEnumerator.MoveNext"]() && e2["System.Collections.IEnumerator.MoveNext"]()) {
|
|
652
|
+
acc = folder(acc, e1["System.Collections.Generic.IEnumerator`1.get_Current"](), e2["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
653
|
+
}
|
|
654
|
+
return acc;
|
|
655
|
+
}
|
|
656
|
+
finally {
|
|
657
|
+
disposeSafe(e2);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
finally {
|
|
661
|
+
disposeSafe(e1);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
export function foldBack2(folder, xs, ys, state) {
|
|
665
|
+
return foldBack2_1(folder, toArray(xs), toArray(ys), state);
|
|
666
|
+
}
|
|
667
|
+
export function forAll(predicate, xs) {
|
|
668
|
+
return !exists((x) => !predicate(x), xs);
|
|
669
|
+
}
|
|
670
|
+
export function forAll2(predicate, xs, ys) {
|
|
671
|
+
return !exists2((x, y) => !predicate(x, y), xs, ys);
|
|
672
|
+
}
|
|
673
|
+
export function tryHead(xs) {
|
|
674
|
+
if (isArrayLike(xs)) {
|
|
675
|
+
return tryHead_1(xs);
|
|
676
|
+
}
|
|
677
|
+
else if (xs instanceof FSharpList) {
|
|
678
|
+
return tryHead_2(xs);
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
const e = ofSeq(xs);
|
|
682
|
+
try {
|
|
683
|
+
return e["System.Collections.IEnumerator.MoveNext"]() ? some(e["System.Collections.Generic.IEnumerator`1.get_Current"]()) : undefined;
|
|
684
|
+
}
|
|
685
|
+
finally {
|
|
686
|
+
disposeSafe(e);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
export function head(xs) {
|
|
691
|
+
const matchValue = tryHead(xs);
|
|
692
|
+
if (matchValue == null) {
|
|
693
|
+
throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
return value_1(matchValue);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
export function initialize(count, f) {
|
|
700
|
+
return unfold((i) => ((i < count) ? [f(i), i + 1] : undefined), 0);
|
|
701
|
+
}
|
|
702
|
+
export function initializeInfinite(f) {
|
|
703
|
+
return initialize(2147483647, f);
|
|
704
|
+
}
|
|
705
|
+
export function isEmpty(xs) {
|
|
706
|
+
if (isArrayLike(xs)) {
|
|
707
|
+
const a = xs;
|
|
708
|
+
return a.length === 0;
|
|
709
|
+
}
|
|
710
|
+
else if (xs instanceof FSharpList) {
|
|
711
|
+
return isEmpty_1(xs);
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
const e = ofSeq(xs);
|
|
715
|
+
try {
|
|
716
|
+
return !e["System.Collections.IEnumerator.MoveNext"]();
|
|
717
|
+
}
|
|
718
|
+
finally {
|
|
719
|
+
disposeSafe(e);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
export function tryItem(index, xs) {
|
|
724
|
+
if (isArrayLike(xs)) {
|
|
725
|
+
return tryItem_1(index, xs);
|
|
726
|
+
}
|
|
727
|
+
else if (xs instanceof FSharpList) {
|
|
728
|
+
return tryItem_2(index, xs);
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
const e = ofSeq(xs);
|
|
732
|
+
try {
|
|
733
|
+
const loop = (index_1_mut) => {
|
|
734
|
+
loop: while (true) {
|
|
735
|
+
const index_1 = index_1_mut;
|
|
736
|
+
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
737
|
+
return undefined;
|
|
738
|
+
}
|
|
739
|
+
else if (index_1 === 0) {
|
|
740
|
+
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
index_1_mut = (index_1 - 1);
|
|
744
|
+
continue loop;
|
|
745
|
+
}
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
return loop(index);
|
|
750
|
+
}
|
|
751
|
+
finally {
|
|
752
|
+
disposeSafe(e);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
export function item(index, xs) {
|
|
757
|
+
const matchValue = tryItem(index, xs);
|
|
758
|
+
if (matchValue == null) {
|
|
759
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "index");
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
return value_1(matchValue);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
export function iterate(action, xs) {
|
|
766
|
+
fold((unitVar, x) => {
|
|
767
|
+
action(x);
|
|
768
|
+
}, undefined, xs);
|
|
769
|
+
}
|
|
770
|
+
export function iterate2(action, xs, ys) {
|
|
771
|
+
fold2((unitVar, x, y) => {
|
|
772
|
+
action(x, y);
|
|
773
|
+
}, undefined, xs, ys);
|
|
774
|
+
}
|
|
775
|
+
export function iterateIndexed(action, xs) {
|
|
776
|
+
fold((i, x) => {
|
|
777
|
+
action(i, x);
|
|
778
|
+
return (i + 1) | 0;
|
|
779
|
+
}, 0, xs);
|
|
780
|
+
}
|
|
781
|
+
export function iterateIndexed2(action, xs, ys) {
|
|
782
|
+
fold2((i, x, y) => {
|
|
783
|
+
action(i, x, y);
|
|
784
|
+
return (i + 1) | 0;
|
|
785
|
+
}, 0, xs, ys);
|
|
786
|
+
}
|
|
787
|
+
export function tryLast(xs) {
|
|
788
|
+
const e = ofSeq(xs);
|
|
789
|
+
try {
|
|
790
|
+
const loop = (acc_mut) => {
|
|
791
|
+
loop: while (true) {
|
|
792
|
+
const acc = acc_mut;
|
|
793
|
+
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
794
|
+
return acc;
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
acc_mut = e["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
798
|
+
continue loop;
|
|
799
|
+
}
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
return e["System.Collections.IEnumerator.MoveNext"]() ? some(loop(e["System.Collections.Generic.IEnumerator`1.get_Current"]())) : undefined;
|
|
804
|
+
}
|
|
805
|
+
finally {
|
|
806
|
+
disposeSafe(e);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
export function last(xs) {
|
|
810
|
+
const matchValue = tryLast(xs);
|
|
811
|
+
if (matchValue == null) {
|
|
812
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "source");
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
return value_1(matchValue);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
export function length(xs) {
|
|
819
|
+
if (isArrayLike(xs)) {
|
|
820
|
+
const a = xs;
|
|
821
|
+
return a.length | 0;
|
|
822
|
+
}
|
|
823
|
+
else if (xs instanceof FSharpList) {
|
|
824
|
+
return length_1(xs) | 0;
|
|
825
|
+
}
|
|
826
|
+
else {
|
|
827
|
+
const e = ofSeq(xs);
|
|
828
|
+
try {
|
|
829
|
+
let count = 0;
|
|
830
|
+
while (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
831
|
+
count = ((count + 1) | 0);
|
|
832
|
+
}
|
|
833
|
+
return count | 0;
|
|
834
|
+
}
|
|
835
|
+
finally {
|
|
836
|
+
disposeSafe(e);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
export function map(mapping, xs) {
|
|
841
|
+
return generate(() => ofSeq(xs), (e) => (e["System.Collections.IEnumerator.MoveNext"]() ? some(mapping(e["System.Collections.Generic.IEnumerator`1.get_Current"]())) : undefined), (e_1) => {
|
|
842
|
+
disposeSafe(e_1);
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
export function mapIndexed(mapping, xs) {
|
|
846
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => (e["System.Collections.IEnumerator.MoveNext"]() ? some(mapping(i, e["System.Collections.Generic.IEnumerator`1.get_Current"]())) : undefined), (e_1) => {
|
|
847
|
+
disposeSafe(e_1);
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
export function indexed(xs) {
|
|
851
|
+
return mapIndexed((i, x) => [i, x], xs);
|
|
852
|
+
}
|
|
853
|
+
export function map2(mapping, xs, ys) {
|
|
854
|
+
return generate(() => [ofSeq(xs), ofSeq(ys)], (tupledArg) => {
|
|
855
|
+
const e1 = tupledArg[0];
|
|
856
|
+
const e2 = tupledArg[1];
|
|
857
|
+
return (e1["System.Collections.IEnumerator.MoveNext"]() && e2["System.Collections.IEnumerator.MoveNext"]()) ? some(mapping(e1["System.Collections.Generic.IEnumerator`1.get_Current"](), e2["System.Collections.Generic.IEnumerator`1.get_Current"]())) : undefined;
|
|
858
|
+
}, (tupledArg_1) => {
|
|
859
|
+
try {
|
|
860
|
+
disposeSafe(tupledArg_1[0]);
|
|
861
|
+
}
|
|
862
|
+
finally {
|
|
863
|
+
disposeSafe(tupledArg_1[1]);
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
export function mapIndexed2(mapping, xs, ys) {
|
|
868
|
+
return generateIndexed(() => [ofSeq(xs), ofSeq(ys)], (i, tupledArg) => {
|
|
869
|
+
const e1 = tupledArg[0];
|
|
870
|
+
const e2 = tupledArg[1];
|
|
871
|
+
return (e1["System.Collections.IEnumerator.MoveNext"]() && e2["System.Collections.IEnumerator.MoveNext"]()) ? some(mapping(i, e1["System.Collections.Generic.IEnumerator`1.get_Current"](), e2["System.Collections.Generic.IEnumerator`1.get_Current"]())) : undefined;
|
|
872
|
+
}, (tupledArg_1) => {
|
|
873
|
+
try {
|
|
874
|
+
disposeSafe(tupledArg_1[0]);
|
|
875
|
+
}
|
|
876
|
+
finally {
|
|
877
|
+
disposeSafe(tupledArg_1[1]);
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
export function map3(mapping, xs, ys, zs) {
|
|
882
|
+
return generate(() => [ofSeq(xs), ofSeq(ys), ofSeq(zs)], (tupledArg) => {
|
|
883
|
+
const e1 = tupledArg[0];
|
|
884
|
+
const e2 = tupledArg[1];
|
|
885
|
+
const e3 = tupledArg[2];
|
|
886
|
+
return ((e1["System.Collections.IEnumerator.MoveNext"]() && e2["System.Collections.IEnumerator.MoveNext"]()) && e3["System.Collections.IEnumerator.MoveNext"]()) ? some(mapping(e1["System.Collections.Generic.IEnumerator`1.get_Current"](), e2["System.Collections.Generic.IEnumerator`1.get_Current"](), e3["System.Collections.Generic.IEnumerator`1.get_Current"]())) : undefined;
|
|
887
|
+
}, (tupledArg_1) => {
|
|
888
|
+
try {
|
|
889
|
+
disposeSafe(tupledArg_1[0]);
|
|
890
|
+
}
|
|
891
|
+
finally {
|
|
892
|
+
try {
|
|
893
|
+
disposeSafe(tupledArg_1[1]);
|
|
894
|
+
}
|
|
895
|
+
finally {
|
|
896
|
+
disposeSafe(tupledArg_1[2]);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
export function readOnly(xs) {
|
|
902
|
+
checkNonNull("source", xs);
|
|
903
|
+
return map((x) => x, xs);
|
|
904
|
+
}
|
|
905
|
+
export class CachedSeq$1 {
|
|
906
|
+
constructor(cleanup, res) {
|
|
907
|
+
this.cleanup = cleanup;
|
|
908
|
+
this.res = res;
|
|
909
|
+
}
|
|
910
|
+
Dispose() {
|
|
911
|
+
const _ = this;
|
|
912
|
+
_.cleanup();
|
|
913
|
+
}
|
|
914
|
+
GetEnumerator() {
|
|
915
|
+
const _ = this;
|
|
916
|
+
return getEnumerator(_.res);
|
|
917
|
+
}
|
|
918
|
+
[Symbol.iterator]() {
|
|
919
|
+
return toIterator(getEnumerator(this));
|
|
920
|
+
}
|
|
921
|
+
"System.Collections.IEnumerable.GetEnumerator"() {
|
|
922
|
+
const _ = this;
|
|
923
|
+
return getEnumerator(_.res);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
export function CachedSeq$1_$reflection(gen0) {
|
|
927
|
+
return class_type("SeqModule.CachedSeq`1", [gen0], CachedSeq$1);
|
|
928
|
+
}
|
|
929
|
+
export function CachedSeq$1_$ctor_Z7A8347D4(cleanup, res) {
|
|
930
|
+
return new CachedSeq$1(cleanup, res);
|
|
931
|
+
}
|
|
932
|
+
export function CachedSeq$1__Clear(_) {
|
|
933
|
+
_.cleanup();
|
|
934
|
+
}
|
|
935
|
+
export function cache(source) {
|
|
936
|
+
checkNonNull("source", source);
|
|
937
|
+
const prefix = [];
|
|
938
|
+
let enumeratorR = undefined;
|
|
939
|
+
return CachedSeq$1_$ctor_Z7A8347D4(() => {
|
|
940
|
+
Operators_Lock(prefix, () => {
|
|
941
|
+
clear(prefix);
|
|
942
|
+
let matchResult, e;
|
|
943
|
+
if (enumeratorR != null) {
|
|
944
|
+
if (value_1(enumeratorR) != null) {
|
|
945
|
+
matchResult = 0;
|
|
946
|
+
e = value_1(value_1(enumeratorR));
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
matchResult = 1;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
else {
|
|
953
|
+
matchResult = 1;
|
|
954
|
+
}
|
|
955
|
+
switch (matchResult) {
|
|
956
|
+
case 0: {
|
|
957
|
+
disposeSafe(e);
|
|
958
|
+
break;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
enumeratorR = undefined;
|
|
962
|
+
});
|
|
963
|
+
}, unfold((i_1) => Operators_Lock(prefix, () => {
|
|
964
|
+
if (i_1 < prefix.length) {
|
|
965
|
+
return [prefix[i_1], i_1 + 1];
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
if (i_1 >= prefix.length) {
|
|
969
|
+
let optEnumerator_2;
|
|
970
|
+
if (enumeratorR != null) {
|
|
971
|
+
optEnumerator_2 = value_1(enumeratorR);
|
|
972
|
+
}
|
|
973
|
+
else {
|
|
974
|
+
const optEnumerator = getEnumerator(source);
|
|
975
|
+
enumeratorR = some(optEnumerator);
|
|
976
|
+
optEnumerator_2 = optEnumerator;
|
|
977
|
+
}
|
|
978
|
+
if (optEnumerator_2 == null) {
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
const enumerator = value_1(optEnumerator_2);
|
|
982
|
+
if (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
983
|
+
void (prefix.push(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()));
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
disposeSafe(enumerator);
|
|
987
|
+
enumeratorR = some(undefined);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (i_1 < prefix.length) {
|
|
992
|
+
return [prefix[i_1], i_1 + 1];
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
return undefined;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}), 0));
|
|
999
|
+
}
|
|
1000
|
+
export function allPairs(xs, ys) {
|
|
1001
|
+
const ysCache = cache(ys);
|
|
1002
|
+
return delay(() => concat(map((x) => map((y) => [x, y], ysCache), xs)));
|
|
1003
|
+
}
|
|
1004
|
+
export function mapFold(mapping, state, xs) {
|
|
1005
|
+
const patternInput = mapFold_1(mapping, state, toArray(xs));
|
|
1006
|
+
return [readOnly(patternInput[0]), patternInput[1]];
|
|
1007
|
+
}
|
|
1008
|
+
export function mapFoldBack(mapping, xs, state) {
|
|
1009
|
+
const patternInput = mapFoldBack_1(mapping, toArray(xs), state);
|
|
1010
|
+
return [readOnly(patternInput[0]), patternInput[1]];
|
|
1011
|
+
}
|
|
1012
|
+
export function tryPick(chooser, xs) {
|
|
1013
|
+
const e = ofSeq(xs);
|
|
1014
|
+
try {
|
|
1015
|
+
let res = undefined;
|
|
1016
|
+
while ((res == null) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1017
|
+
res = chooser(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1018
|
+
}
|
|
1019
|
+
return res;
|
|
1020
|
+
}
|
|
1021
|
+
finally {
|
|
1022
|
+
disposeSafe(e);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
export function pick(chooser, xs) {
|
|
1026
|
+
const matchValue = tryPick(chooser, xs);
|
|
1027
|
+
if (matchValue == null) {
|
|
1028
|
+
return indexNotFound();
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
return value_1(matchValue);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
export function reduce(folder, xs) {
|
|
1035
|
+
const e = ofSeq(xs);
|
|
1036
|
+
try {
|
|
1037
|
+
const loop = (acc_mut) => {
|
|
1038
|
+
loop: while (true) {
|
|
1039
|
+
const acc = acc_mut;
|
|
1040
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1041
|
+
acc_mut = folder(acc, e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1042
|
+
continue loop;
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
return acc;
|
|
1046
|
+
}
|
|
1047
|
+
break;
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1051
|
+
return loop(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
throw new Error(SR_inputSequenceEmpty);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
finally {
|
|
1058
|
+
disposeSafe(e);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
export function reduceBack(folder, xs) {
|
|
1062
|
+
const arr = toArray(xs);
|
|
1063
|
+
if (arr.length > 0) {
|
|
1064
|
+
return arr.reduceRight(folder);
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
throw new Error(SR_inputSequenceEmpty);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
export function replicate(n, x) {
|
|
1071
|
+
return initialize(n, (_arg) => x);
|
|
1072
|
+
}
|
|
1073
|
+
export function reverse(xs) {
|
|
1074
|
+
return delay(() => ofArray(reverse_1(toArray(xs))));
|
|
1075
|
+
}
|
|
1076
|
+
export function scan(folder, state, xs) {
|
|
1077
|
+
return delay(() => {
|
|
1078
|
+
let acc = state;
|
|
1079
|
+
return concat([singleton(state), map((x) => {
|
|
1080
|
+
acc = folder(acc, x);
|
|
1081
|
+
return acc;
|
|
1082
|
+
}, xs)]);
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
export function scanBack(folder, xs, state) {
|
|
1086
|
+
return delay(() => ofArray(scanBack_1(folder, toArray(xs), state)));
|
|
1087
|
+
}
|
|
1088
|
+
export function skip(count, source) {
|
|
1089
|
+
return mkSeq(() => {
|
|
1090
|
+
const e = ofSeq(source);
|
|
1091
|
+
try {
|
|
1092
|
+
for (let _ = 1; _ <= count; _++) {
|
|
1093
|
+
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1094
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "source");
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return Enumerator_enumerateThenFinally(() => {
|
|
1098
|
+
}, e);
|
|
1099
|
+
}
|
|
1100
|
+
catch (matchValue) {
|
|
1101
|
+
disposeSafe(e);
|
|
1102
|
+
throw matchValue;
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
export function skipWhile(predicate, xs) {
|
|
1107
|
+
return delay(() => {
|
|
1108
|
+
let skipped = true;
|
|
1109
|
+
return filter((x) => {
|
|
1110
|
+
if (skipped) {
|
|
1111
|
+
skipped = predicate(x);
|
|
1112
|
+
}
|
|
1113
|
+
return !skipped;
|
|
1114
|
+
}, xs);
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
export function tail(xs) {
|
|
1118
|
+
return skip(1, xs);
|
|
1119
|
+
}
|
|
1120
|
+
export function take(count, xs) {
|
|
1121
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1122
|
+
if (i < count) {
|
|
1123
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1124
|
+
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
throw new Error((SR_notEnoughElements + "\\nParameter name: ") + "source");
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
return undefined;
|
|
1132
|
+
}
|
|
1133
|
+
}, (e_1) => {
|
|
1134
|
+
disposeSafe(e_1);
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
export function takeWhile(predicate, xs) {
|
|
1138
|
+
return generate(() => ofSeq(xs), (e) => ((e["System.Collections.IEnumerator.MoveNext"]() && predicate(e["System.Collections.Generic.IEnumerator`1.get_Current"]())) ? some(e["System.Collections.Generic.IEnumerator`1.get_Current"]()) : undefined), (e_1) => {
|
|
1139
|
+
disposeSafe(e_1);
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
export function truncate(count, xs) {
|
|
1143
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => (((i < count) && e["System.Collections.IEnumerator.MoveNext"]()) ? some(e["System.Collections.Generic.IEnumerator`1.get_Current"]()) : undefined), (e_1) => {
|
|
1144
|
+
disposeSafe(e_1);
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
export function zip(xs, ys) {
|
|
1148
|
+
return map2((x, y) => [x, y], xs, ys);
|
|
1149
|
+
}
|
|
1150
|
+
export function zip3(xs, ys, zs) {
|
|
1151
|
+
return map3((x, y, z) => [x, y, z], xs, ys, zs);
|
|
1152
|
+
}
|
|
1153
|
+
export function collect(mapping, xs) {
|
|
1154
|
+
return delay(() => concat(map(mapping, xs)));
|
|
1155
|
+
}
|
|
1156
|
+
export function where(predicate, xs) {
|
|
1157
|
+
return filter(predicate, xs);
|
|
1158
|
+
}
|
|
1159
|
+
export function pairwise(xs) {
|
|
1160
|
+
return delay(() => ofArray(pairwise_1(toArray(xs))));
|
|
1161
|
+
}
|
|
1162
|
+
export function splitInto(chunks, xs) {
|
|
1163
|
+
return delay(() => ofArray(splitInto_1(chunks, toArray(xs))));
|
|
1164
|
+
}
|
|
1165
|
+
export function windowed(windowSize, xs) {
|
|
1166
|
+
return delay(() => ofArray(windowed_1(windowSize, toArray(xs))));
|
|
1167
|
+
}
|
|
1168
|
+
export function transpose(xss) {
|
|
1169
|
+
return delay(() => ofArray(map_1(ofArray, transpose_1(map_1(toArray, toArray(xss))))));
|
|
1170
|
+
}
|
|
1171
|
+
export function sortWith(comparer, xs) {
|
|
1172
|
+
return delay(() => {
|
|
1173
|
+
const arr = toArray(xs);
|
|
1174
|
+
arr.sort(comparer);
|
|
1175
|
+
return ofArray(arr);
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
export function sort(xs, comparer) {
|
|
1179
|
+
return sortWith((x, y) => comparer.Compare(x, y), xs);
|
|
1180
|
+
}
|
|
1181
|
+
export function sortBy(projection, xs, comparer) {
|
|
1182
|
+
return sortWith((x, y) => comparer.Compare(projection(x), projection(y)), xs);
|
|
1183
|
+
}
|
|
1184
|
+
export function sortDescending(xs, comparer) {
|
|
1185
|
+
return sortWith((x, y) => (comparer.Compare(x, y) * -1), xs);
|
|
1186
|
+
}
|
|
1187
|
+
export function sortByDescending(projection, xs, comparer) {
|
|
1188
|
+
return sortWith((x, y) => (comparer.Compare(projection(x), projection(y)) * -1), xs);
|
|
1189
|
+
}
|
|
1190
|
+
export function sum(xs, adder) {
|
|
1191
|
+
return fold((acc, x) => adder.Add(acc, x), adder.GetZero(), xs);
|
|
1192
|
+
}
|
|
1193
|
+
export function sumBy(f, xs, adder) {
|
|
1194
|
+
return fold((acc, x) => adder.Add(acc, f(x)), adder.GetZero(), xs);
|
|
1195
|
+
}
|
|
1196
|
+
export function maxBy(projection, xs, comparer) {
|
|
1197
|
+
return reduce((x, y) => ((comparer.Compare(projection(y), projection(x)) > 0) ? y : x), xs);
|
|
1198
|
+
}
|
|
1199
|
+
export function max(xs, comparer) {
|
|
1200
|
+
return reduce((x, y) => ((comparer.Compare(y, x) > 0) ? y : x), xs);
|
|
1201
|
+
}
|
|
1202
|
+
export function minBy(projection, xs, comparer) {
|
|
1203
|
+
return reduce((x, y) => ((comparer.Compare(projection(y), projection(x)) > 0) ? x : y), xs);
|
|
1204
|
+
}
|
|
1205
|
+
export function min(xs, comparer) {
|
|
1206
|
+
return reduce((x, y) => ((comparer.Compare(y, x) > 0) ? x : y), xs);
|
|
1207
|
+
}
|
|
1208
|
+
export function average(xs, averager) {
|
|
1209
|
+
let count = 0;
|
|
1210
|
+
const total = fold((acc, x) => {
|
|
1211
|
+
count = ((count + 1) | 0);
|
|
1212
|
+
return averager.Add(acc, x);
|
|
1213
|
+
}, averager.GetZero(), xs);
|
|
1214
|
+
if (count === 0) {
|
|
1215
|
+
throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
return averager.DivideByInt(total, count);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
export function averageBy(f, xs, averager) {
|
|
1222
|
+
let count = 0;
|
|
1223
|
+
const total = fold((acc, x) => {
|
|
1224
|
+
count = ((count + 1) | 0);
|
|
1225
|
+
return averager.Add(acc, f(x));
|
|
1226
|
+
}, averager.GetZero(), xs);
|
|
1227
|
+
if (count === 0) {
|
|
1228
|
+
throw new Error((SR_inputSequenceEmpty + "\\nParameter name: ") + "source");
|
|
1229
|
+
}
|
|
1230
|
+
else {
|
|
1231
|
+
return averager.DivideByInt(total, count);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
export function permute(f, xs) {
|
|
1235
|
+
return delay(() => ofArray(permute_1(f, toArray(xs))));
|
|
1236
|
+
}
|
|
1237
|
+
export function chunkBySize(chunkSize, xs) {
|
|
1238
|
+
return delay(() => ofArray(chunkBySize_1(chunkSize, toArray(xs))));
|
|
1239
|
+
}
|
|
1240
|
+
export function insertAt(index, y, xs) {
|
|
1241
|
+
let isDone = false;
|
|
1242
|
+
if (index < 0) {
|
|
1243
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1244
|
+
}
|
|
1245
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1246
|
+
if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1247
|
+
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1248
|
+
}
|
|
1249
|
+
else if (i === index) {
|
|
1250
|
+
isDone = true;
|
|
1251
|
+
return some(y);
|
|
1252
|
+
}
|
|
1253
|
+
else {
|
|
1254
|
+
if (!isDone) {
|
|
1255
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1256
|
+
}
|
|
1257
|
+
return undefined;
|
|
1258
|
+
}
|
|
1259
|
+
}, (e_1) => {
|
|
1260
|
+
disposeSafe(e_1);
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
export function insertManyAt(index, ys, xs) {
|
|
1264
|
+
let status = -1;
|
|
1265
|
+
if (index < 0) {
|
|
1266
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1267
|
+
}
|
|
1268
|
+
return generateIndexed(() => [ofSeq(xs), ofSeq(ys)], (i, tupledArg) => {
|
|
1269
|
+
const e1 = tupledArg[0];
|
|
1270
|
+
const e2 = tupledArg[1];
|
|
1271
|
+
if (i === index) {
|
|
1272
|
+
status = 0;
|
|
1273
|
+
}
|
|
1274
|
+
let inserted;
|
|
1275
|
+
if (status === 0) {
|
|
1276
|
+
if (e2["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1277
|
+
inserted = some(e2["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
status = 1;
|
|
1281
|
+
inserted = undefined;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
inserted = undefined;
|
|
1286
|
+
}
|
|
1287
|
+
if (inserted == null) {
|
|
1288
|
+
if (e1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1289
|
+
return some(e1["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
if (status < 1) {
|
|
1293
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1294
|
+
}
|
|
1295
|
+
return undefined;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
return some(value_1(inserted));
|
|
1300
|
+
}
|
|
1301
|
+
}, (tupledArg_1) => {
|
|
1302
|
+
disposeSafe(tupledArg_1[0]);
|
|
1303
|
+
disposeSafe(tupledArg_1[1]);
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
export function removeAt(index, xs) {
|
|
1307
|
+
let isDone = false;
|
|
1308
|
+
if (index < 0) {
|
|
1309
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1310
|
+
}
|
|
1311
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1312
|
+
if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1313
|
+
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1314
|
+
}
|
|
1315
|
+
else if ((i === index) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1316
|
+
isDone = true;
|
|
1317
|
+
return e["System.Collections.IEnumerator.MoveNext"]() ? some(e["System.Collections.Generic.IEnumerator`1.get_Current"]()) : undefined;
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
if (!isDone) {
|
|
1321
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1322
|
+
}
|
|
1323
|
+
return undefined;
|
|
1324
|
+
}
|
|
1325
|
+
}, (e_1) => {
|
|
1326
|
+
disposeSafe(e_1);
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
export function removeManyAt(index, count, xs) {
|
|
1330
|
+
if (index < 0) {
|
|
1331
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1332
|
+
}
|
|
1333
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1334
|
+
if (i < index) {
|
|
1335
|
+
if (e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1336
|
+
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
else {
|
|
1343
|
+
if (i === index) {
|
|
1344
|
+
for (let _ = 1; _ <= count; _++) {
|
|
1345
|
+
if (!e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1346
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "count");
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
return e["System.Collections.IEnumerator.MoveNext"]() ? some(e["System.Collections.Generic.IEnumerator`1.get_Current"]()) : undefined;
|
|
1351
|
+
}
|
|
1352
|
+
}, (e_1) => {
|
|
1353
|
+
disposeSafe(e_1);
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
export function updateAt(index, y, xs) {
|
|
1357
|
+
let isDone = false;
|
|
1358
|
+
if (index < 0) {
|
|
1359
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1360
|
+
}
|
|
1361
|
+
return generateIndexed(() => ofSeq(xs), (i, e) => {
|
|
1362
|
+
if ((isDone ? true : (i < index)) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1363
|
+
return some(e["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
1364
|
+
}
|
|
1365
|
+
else if ((i === index) && e["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1366
|
+
isDone = true;
|
|
1367
|
+
return some(y);
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
if (!isDone) {
|
|
1371
|
+
throw new Error((SR_indexOutOfBounds + "\\nParameter name: ") + "index");
|
|
1372
|
+
}
|
|
1373
|
+
return undefined;
|
|
1374
|
+
}
|
|
1375
|
+
}, (e_1) => {
|
|
1376
|
+
disposeSafe(e_1);
|
|
1377
|
+
});
|
|
1378
|
+
}
|