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