@fable-org/fable-library-ts 2.0.0-beta.4 → 2.0.0-beta.5

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