pure-dango 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/package.json +45 -0
- package/src/core/compiler.ts +1269 -0
- package/src/core/interpreter.ts +2042 -0
- package/src/core/parser/handlers.ts +1091 -0
- package/src/core/parser/helpers.ts +157 -0
- package/src/core/parser/main.ts +620 -0
- package/src/core/tokenizer/funnies.ts +43 -0
- package/src/core/tokenizer/tokenizer.ts +334 -0
- package/src/core/utils.ts +534 -0
- package/src/index.ts +190 -0
- package/src/runtime/errors.ts +239 -0
- package/src/runtime/globals.ts +11 -0
- package/src/runtime/libs/ai.pds +56 -0
- package/src/runtime/libs/errors.pds +74 -0
- package/src/runtime/libs/gambling.pds +93 -0
- package/src/runtime/libs/io.pds +371 -0
- package/src/runtime/libs/math.pds +86 -0
- package/src/runtime/libs/std.pds +2 -0
- package/src/runtime/libs/types.pds +1232 -0
- package/src/runtime/stdlib.ts +1483 -0
|
@@ -0,0 +1,1232 @@
|
|
|
1
|
+
# all normal classes needed.
|
|
2
|
+
# Don't use BaseArray. Import this from stdtyp.pds using import internal "stdtyp.pds" not directly.
|
|
3
|
+
|
|
4
|
+
import "errors.pds";
|
|
5
|
+
|
|
6
|
+
class BaseArray
|
|
7
|
+
{
|
|
8
|
+
constructor(x)
|
|
9
|
+
this.__INIT__ = x;
|
|
10
|
+
|
|
11
|
+
indexOf(x)
|
|
12
|
+
{
|
|
13
|
+
new val = this.__INIT__;
|
|
14
|
+
new length = len(val);
|
|
15
|
+
|
|
16
|
+
new xLength = len(x);
|
|
17
|
+
new isX = true;
|
|
18
|
+
|
|
19
|
+
new i, j = 0, 0;
|
|
20
|
+
new xIndex = 0;
|
|
21
|
+
for (i = 0; i < length; i++)
|
|
22
|
+
{
|
|
23
|
+
isX = true;
|
|
24
|
+
for (j = 0; j < xLength; j++)
|
|
25
|
+
{
|
|
26
|
+
if (val[j + i] != x[j])
|
|
27
|
+
{
|
|
28
|
+
isX = false;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (isX)
|
|
34
|
+
return i;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
length()
|
|
41
|
+
return len(this.__INIT__);
|
|
42
|
+
|
|
43
|
+
toString()
|
|
44
|
+
return tostr(this.__INIT__);
|
|
45
|
+
|
|
46
|
+
isEmpty()
|
|
47
|
+
return len(this.__INIT__) == 0;
|
|
48
|
+
|
|
49
|
+
first()
|
|
50
|
+
return this.__INIT__[0];
|
|
51
|
+
|
|
52
|
+
last()
|
|
53
|
+
{
|
|
54
|
+
new val = this.__INIT__;
|
|
55
|
+
return val[len(val) - 1];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function QuickSort(val)
|
|
60
|
+
{
|
|
61
|
+
new length = len(val);
|
|
62
|
+
if (length <= 1)
|
|
63
|
+
return val;
|
|
64
|
+
|
|
65
|
+
new pivot = val[0];
|
|
66
|
+
new leftArray = [];
|
|
67
|
+
new rightArray = [];
|
|
68
|
+
|
|
69
|
+
new i = 0;
|
|
70
|
+
new item;
|
|
71
|
+
for (i = 1; i < length; i++)
|
|
72
|
+
{
|
|
73
|
+
item = val[i];
|
|
74
|
+
|
|
75
|
+
if (item <= pivot)
|
|
76
|
+
push(leftArray, item);
|
|
77
|
+
else
|
|
78
|
+
push(rightArray, item);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
new sortedLeft = QuickSort(leftArray);
|
|
82
|
+
new sortedRight = QuickSort(rightArray);
|
|
83
|
+
|
|
84
|
+
new result = [];
|
|
85
|
+
new leftLength = len(leftArray);
|
|
86
|
+
new rightLength = len(rightArray);
|
|
87
|
+
|
|
88
|
+
new j = 0;
|
|
89
|
+
for (j = 0; j < leftLength; j++)
|
|
90
|
+
push(result, sortedLeft[j])
|
|
91
|
+
|
|
92
|
+
push(result, pivot);
|
|
93
|
+
|
|
94
|
+
for (j = 0; j < rightLength; j++)
|
|
95
|
+
push(result, sortedRight[j])
|
|
96
|
+
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
class Array extends BaseArray
|
|
101
|
+
{
|
|
102
|
+
constructor(x)
|
|
103
|
+
{
|
|
104
|
+
x = toarr(x);
|
|
105
|
+
super(x);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
indexOf(x)
|
|
109
|
+
{
|
|
110
|
+
new val = this.__INIT__;
|
|
111
|
+
new length = len(val);
|
|
112
|
+
|
|
113
|
+
new i = 0;
|
|
114
|
+
for (i = 0; i < length; i++)
|
|
115
|
+
if (val[i] == x)
|
|
116
|
+
return i;
|
|
117
|
+
|
|
118
|
+
return -1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
push(x)
|
|
122
|
+
push(this.__INIT__, x)
|
|
123
|
+
|
|
124
|
+
pop()
|
|
125
|
+
return pop(this.__INIT__);
|
|
126
|
+
|
|
127
|
+
set(i, y)
|
|
128
|
+
{
|
|
129
|
+
new result = [];
|
|
130
|
+
new val = this.__INIT__;
|
|
131
|
+
new length = len(val);
|
|
132
|
+
|
|
133
|
+
new j = 0;
|
|
134
|
+
for (j = 0; j < length; j++)
|
|
135
|
+
{
|
|
136
|
+
if (j == i)
|
|
137
|
+
push(result, y)
|
|
138
|
+
else
|
|
139
|
+
push(result, val[j]);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.__INIT__ = result;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
insert(i, y)
|
|
146
|
+
{
|
|
147
|
+
new result = [];
|
|
148
|
+
new val = this.__INIT__;
|
|
149
|
+
new length = len(val);
|
|
150
|
+
|
|
151
|
+
new j = 0;
|
|
152
|
+
for (j = 0; j < length; j++)
|
|
153
|
+
{
|
|
154
|
+
if (j == i)
|
|
155
|
+
push(result, y);
|
|
156
|
+
|
|
157
|
+
push(result, val[j]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
this.__INIT__ = result;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
remove(i)
|
|
164
|
+
{
|
|
165
|
+
new result = [];
|
|
166
|
+
new val = this.__INIT__;
|
|
167
|
+
new length = len(val);
|
|
168
|
+
|
|
169
|
+
new j = 0;
|
|
170
|
+
for (j = 0; j < length; j++)
|
|
171
|
+
{
|
|
172
|
+
if (j == i)
|
|
173
|
+
continue;
|
|
174
|
+
|
|
175
|
+
push(result, val[j]);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.__INIT__ = result;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
join(x)
|
|
182
|
+
{
|
|
183
|
+
new result = "";
|
|
184
|
+
new val = this.__INIT__;
|
|
185
|
+
new length = len(val);
|
|
186
|
+
|
|
187
|
+
new i = 0;
|
|
188
|
+
for (i = 0; i < length; i++)
|
|
189
|
+
{
|
|
190
|
+
concat(result, val[i]);
|
|
191
|
+
if (i < length - 1)
|
|
192
|
+
concat(result, x);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
slice(x, y)
|
|
199
|
+
{
|
|
200
|
+
new result = [];
|
|
201
|
+
|
|
202
|
+
new val = this.__INIT__;
|
|
203
|
+
|
|
204
|
+
if (y == undefined || y == null)
|
|
205
|
+
y = len(val);
|
|
206
|
+
|
|
207
|
+
new i = 0;
|
|
208
|
+
for (i = x; i < y; i++)
|
|
209
|
+
push(result, val[i]);
|
|
210
|
+
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
contains(x)
|
|
215
|
+
{
|
|
216
|
+
new val = this.__INIT__;
|
|
217
|
+
new length = len(val);
|
|
218
|
+
|
|
219
|
+
new i = 0;
|
|
220
|
+
new contains = false;
|
|
221
|
+
for (i = 0; i < length; i++)
|
|
222
|
+
if (x == val[i])
|
|
223
|
+
contains = true;
|
|
224
|
+
|
|
225
|
+
return contains;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
reverse()
|
|
229
|
+
{
|
|
230
|
+
new result = [];
|
|
231
|
+
|
|
232
|
+
new val = this.__INIT__;
|
|
233
|
+
new length = len(val);
|
|
234
|
+
|
|
235
|
+
new i = 0;
|
|
236
|
+
for (i = length-1; i >= 0; i--)
|
|
237
|
+
push(result, val[i]);
|
|
238
|
+
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
concat(x)
|
|
243
|
+
{
|
|
244
|
+
new result = this.__INIT__;
|
|
245
|
+
|
|
246
|
+
new xLength = len(x);
|
|
247
|
+
|
|
248
|
+
new i = 0;
|
|
249
|
+
for (i = 0; i < xLength; i++)
|
|
250
|
+
push(result, x[i]);
|
|
251
|
+
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
unique()
|
|
256
|
+
{
|
|
257
|
+
new result = [];
|
|
258
|
+
new seen = {};
|
|
259
|
+
|
|
260
|
+
new val = this.__INIT__;
|
|
261
|
+
new length = len(val);
|
|
262
|
+
|
|
263
|
+
new i = 0;
|
|
264
|
+
new current;
|
|
265
|
+
for (i = 0; i < length; i++)
|
|
266
|
+
{
|
|
267
|
+
current = val[i];
|
|
268
|
+
if (seen[current] == undefined)
|
|
269
|
+
{
|
|
270
|
+
push(result, current);
|
|
271
|
+
seen[current] = true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
sort()
|
|
279
|
+
return QuickSort(this.__INIT__);
|
|
280
|
+
|
|
281
|
+
map(fn)
|
|
282
|
+
{
|
|
283
|
+
new result = [];
|
|
284
|
+
|
|
285
|
+
new val = this.__INIT__;
|
|
286
|
+
new length = len(val);
|
|
287
|
+
|
|
288
|
+
new i = 0;
|
|
289
|
+
for (i = 0; i < length; i++)
|
|
290
|
+
push(result, fn(val[i]));
|
|
291
|
+
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
filter(fn)
|
|
296
|
+
{
|
|
297
|
+
new result = [];
|
|
298
|
+
|
|
299
|
+
new val = this.__INIT__;
|
|
300
|
+
new length = len(val);
|
|
301
|
+
|
|
302
|
+
new i = 0;
|
|
303
|
+
for (i = 0; i < length; i++)
|
|
304
|
+
if (fn(val[i]))
|
|
305
|
+
push(result, val[i]);
|
|
306
|
+
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
reduce(fn, init)
|
|
311
|
+
{
|
|
312
|
+
new accumulator = init;
|
|
313
|
+
|
|
314
|
+
new val = this.__INIT__;
|
|
315
|
+
new length = len(val);
|
|
316
|
+
|
|
317
|
+
new i = 0;
|
|
318
|
+
for (i = 0; i < length; i++)
|
|
319
|
+
accumulator = fn(accumulator, val[i]);
|
|
320
|
+
|
|
321
|
+
return accumulator;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
zip(x)
|
|
325
|
+
{
|
|
326
|
+
if (typeof(x) != "array")
|
|
327
|
+
TypeError.throw('Parameter x of function "zip" should be type "Array". But got "', x, '"');
|
|
328
|
+
|
|
329
|
+
new result = [];
|
|
330
|
+
new val = this.__INIT__;
|
|
331
|
+
|
|
332
|
+
new length;
|
|
333
|
+
if (len(x) > len(val))
|
|
334
|
+
length = len(val);
|
|
335
|
+
else
|
|
336
|
+
length = len(x);
|
|
337
|
+
|
|
338
|
+
new i = 0;
|
|
339
|
+
for (i = 0; i < length; i++)
|
|
340
|
+
push(result, [val[i], x[i]]);
|
|
341
|
+
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
intersection(x)
|
|
346
|
+
{
|
|
347
|
+
if (typeof(x) != "array")
|
|
348
|
+
TypeError.throw('Parameter x of function "intersection" should be type "Array". But got "', x, '"');
|
|
349
|
+
|
|
350
|
+
new result = [];
|
|
351
|
+
new val = this.__INIT__;
|
|
352
|
+
|
|
353
|
+
new length = len(x);
|
|
354
|
+
|
|
355
|
+
new i = 0;
|
|
356
|
+
for (i = 0; i < length; i++)
|
|
357
|
+
if (this.contains(x[i]))
|
|
358
|
+
push(result, x[i]);
|
|
359
|
+
|
|
360
|
+
return result;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
difference(x)
|
|
364
|
+
{
|
|
365
|
+
if (typeof(x) != "array")
|
|
366
|
+
TypeError.throw('Parameter x of function "difference" should be type "Array". But got "', x, '"');
|
|
367
|
+
|
|
368
|
+
new result = [];
|
|
369
|
+
|
|
370
|
+
new val = this.__INIT__;
|
|
371
|
+
new length = len(val);
|
|
372
|
+
|
|
373
|
+
new tempX = inst Array(x);
|
|
374
|
+
|
|
375
|
+
new i = 0;
|
|
376
|
+
for (i = 0; i < length; i++)
|
|
377
|
+
if (!tempX.contains(val[i]))
|
|
378
|
+
push(result, val[i]);
|
|
379
|
+
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
rotate(x)
|
|
384
|
+
{
|
|
385
|
+
if (typeof(x) != "number")
|
|
386
|
+
TypeError.throw('Parameter x of function "rotate" should be type "Number". But got "', x, '"');
|
|
387
|
+
|
|
388
|
+
new result = [];
|
|
389
|
+
|
|
390
|
+
new val = this.__INIT__;
|
|
391
|
+
new length = len(val);
|
|
392
|
+
|
|
393
|
+
x = x % length;
|
|
394
|
+
|
|
395
|
+
new i = 0;
|
|
396
|
+
for (i = x; i < length; i++)
|
|
397
|
+
push(result, val[i]);
|
|
398
|
+
|
|
399
|
+
for (i = 0; i < x; i++)
|
|
400
|
+
push(result, val[i]);
|
|
401
|
+
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
min()
|
|
406
|
+
{
|
|
407
|
+
new val = this.__INIT__;
|
|
408
|
+
new length = len(val);
|
|
409
|
+
|
|
410
|
+
new minimum = val[0];
|
|
411
|
+
|
|
412
|
+
new i = 0;
|
|
413
|
+
for (i = 0; i < length; i++)
|
|
414
|
+
if (val[i] < minimum)
|
|
415
|
+
minimum = val[i];
|
|
416
|
+
|
|
417
|
+
return minimum;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
max()
|
|
421
|
+
{
|
|
422
|
+
new val = this.__INIT__;
|
|
423
|
+
new length = len(val);
|
|
424
|
+
|
|
425
|
+
new maximum = val[0];
|
|
426
|
+
|
|
427
|
+
new i = 0;
|
|
428
|
+
for (i = 0; i < length; i++)
|
|
429
|
+
if (val[i] > maximum)
|
|
430
|
+
maximum = val[i];
|
|
431
|
+
|
|
432
|
+
return maximum;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
chunk(x)
|
|
436
|
+
{
|
|
437
|
+
if (typeof(x) != "number")
|
|
438
|
+
TypeError.throw('Parameter x of function "chunk" should be type "Number". But got "', x, '"');
|
|
439
|
+
|
|
440
|
+
new chunks = [];
|
|
441
|
+
new val = this.__INIT__;
|
|
442
|
+
new length = len(val);
|
|
443
|
+
|
|
444
|
+
new i, j = 0, 0;
|
|
445
|
+
while (i < length)
|
|
446
|
+
{
|
|
447
|
+
new items = [];
|
|
448
|
+
for (j = i; j < i + x && j < length; j++)
|
|
449
|
+
push(items, val[j]);
|
|
450
|
+
|
|
451
|
+
push(chunks, items);
|
|
452
|
+
i += x;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return chunks;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
flat()
|
|
459
|
+
{
|
|
460
|
+
new result = [];
|
|
461
|
+
|
|
462
|
+
new val = this.__INIT__;
|
|
463
|
+
new length = len(val);
|
|
464
|
+
|
|
465
|
+
new i = 0;
|
|
466
|
+
for (i = 0; i < length; i++)
|
|
467
|
+
{
|
|
468
|
+
if (typeof(val[i]) == "array")
|
|
469
|
+
{
|
|
470
|
+
new inner = inst Array(val[i]);
|
|
471
|
+
new flattened = inner.flat();
|
|
472
|
+
new flatLength = len(flattened);
|
|
473
|
+
|
|
474
|
+
new j = 0;
|
|
475
|
+
for (j = 0; j < flatLength; j++)
|
|
476
|
+
push(result, flattened[j]);
|
|
477
|
+
}
|
|
478
|
+
else
|
|
479
|
+
push(result, val[i]);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return result;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
flatten(x)
|
|
486
|
+
{
|
|
487
|
+
new result = [];
|
|
488
|
+
|
|
489
|
+
new val = this.__INIT__;
|
|
490
|
+
new length = len(val);
|
|
491
|
+
|
|
492
|
+
new i = 0;
|
|
493
|
+
for (i = 0; i < length; i++)
|
|
494
|
+
{
|
|
495
|
+
if (typeof(val[i]) == "array")
|
|
496
|
+
{
|
|
497
|
+
if (x <= 0)
|
|
498
|
+
push(result, val[i]);
|
|
499
|
+
else
|
|
500
|
+
{
|
|
501
|
+
new inner = inst Array(val[i]);
|
|
502
|
+
|
|
503
|
+
new flattened = inner.flatten(x - 1);
|
|
504
|
+
new flatLength = len(flattened);
|
|
505
|
+
|
|
506
|
+
new j = 0;
|
|
507
|
+
for (j = 0; j < flatLength; j++)
|
|
508
|
+
push(result, flattened[j]);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
else
|
|
512
|
+
push(result, val[i]);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
find(fn)
|
|
519
|
+
{
|
|
520
|
+
new val = this.__INIT__;
|
|
521
|
+
new length = len(val);
|
|
522
|
+
|
|
523
|
+
new i = 0;
|
|
524
|
+
for (i = 0; i < length; i++)
|
|
525
|
+
if (fn(val[i]))
|
|
526
|
+
return val[i];
|
|
527
|
+
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
findIndex(fn)
|
|
532
|
+
{
|
|
533
|
+
new val = this.__INIT__;
|
|
534
|
+
new length = len(val);
|
|
535
|
+
|
|
536
|
+
new i = 0;
|
|
537
|
+
for (i = 0; i < length; i++)
|
|
538
|
+
if (fn(val[i]))
|
|
539
|
+
return i;
|
|
540
|
+
|
|
541
|
+
return -1;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
forEachWithIndex(fn)
|
|
545
|
+
{
|
|
546
|
+
new val = this.__INIT__;
|
|
547
|
+
new length = len(val);
|
|
548
|
+
|
|
549
|
+
new i = 0;
|
|
550
|
+
for (i = 0; i < length; i++)
|
|
551
|
+
fn(val[i], i);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
countBy(fn)
|
|
555
|
+
{
|
|
556
|
+
new result = {};
|
|
557
|
+
|
|
558
|
+
new val = this.__INIT__;
|
|
559
|
+
new length = len(val);
|
|
560
|
+
|
|
561
|
+
new i = 0;
|
|
562
|
+
for (i = 0; i < length; i++)
|
|
563
|
+
{
|
|
564
|
+
new returned = fn(val[i]);
|
|
565
|
+
if (result[returned] == null || result[returned] == undefined)
|
|
566
|
+
result[returned] = 1;
|
|
567
|
+
else
|
|
568
|
+
result[returned]++;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return result;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
groupBy(fn)
|
|
575
|
+
{
|
|
576
|
+
new result = {};
|
|
577
|
+
|
|
578
|
+
new val = this.__INIT__;
|
|
579
|
+
new length = len(val);
|
|
580
|
+
|
|
581
|
+
new i = 0;
|
|
582
|
+
for (i = 0; i < length; i++)
|
|
583
|
+
{
|
|
584
|
+
new returned = fn(val[i]);
|
|
585
|
+
if (result[returned] == null || result[returned] == undefined)
|
|
586
|
+
result[returned] = [val[i]];
|
|
587
|
+
else
|
|
588
|
+
push(result[returned], val[i]);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
takeWhile(fn)
|
|
595
|
+
{
|
|
596
|
+
new result = [];
|
|
597
|
+
|
|
598
|
+
new val = this.__INIT__;
|
|
599
|
+
new length = len(val);
|
|
600
|
+
|
|
601
|
+
new i = 0;
|
|
602
|
+
while (i < length && fn(val[i]))
|
|
603
|
+
{
|
|
604
|
+
push(result, val[i]);
|
|
605
|
+
i++;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return result;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
dropWhile(fn)
|
|
612
|
+
{
|
|
613
|
+
new result = [];
|
|
614
|
+
|
|
615
|
+
new val = this.__INIT__;
|
|
616
|
+
new length = len(val);
|
|
617
|
+
|
|
618
|
+
new i = 0;
|
|
619
|
+
while (i < length && fn(val[i]))
|
|
620
|
+
i++;
|
|
621
|
+
|
|
622
|
+
while (i < length)
|
|
623
|
+
{
|
|
624
|
+
push(result, val[i]);
|
|
625
|
+
i++;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return result;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
partition(fn)
|
|
632
|
+
{
|
|
633
|
+
new trueList = [];
|
|
634
|
+
new falseList = [];
|
|
635
|
+
|
|
636
|
+
new val = this.__INIT__;
|
|
637
|
+
new length = len(val);
|
|
638
|
+
|
|
639
|
+
new i = 0;
|
|
640
|
+
for (i = 0; i < length; i++)
|
|
641
|
+
{
|
|
642
|
+
if (fn(val[i]))
|
|
643
|
+
push(trueList, val[i]);
|
|
644
|
+
else
|
|
645
|
+
push(falseList, val[i]);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
return [trueList, falseList];
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
every(fn)
|
|
652
|
+
{
|
|
653
|
+
new val = this.__INIT__;
|
|
654
|
+
new length = len(val);
|
|
655
|
+
|
|
656
|
+
new i = 0;
|
|
657
|
+
for (i = 0; i < length; i++)
|
|
658
|
+
if (!fn(val[i]))
|
|
659
|
+
return false;
|
|
660
|
+
|
|
661
|
+
return true;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
some(fn)
|
|
665
|
+
{
|
|
666
|
+
new val = this.__INIT__;
|
|
667
|
+
new length = len(val);
|
|
668
|
+
|
|
669
|
+
new i = 0;
|
|
670
|
+
for (i = 0; i < length; i++)
|
|
671
|
+
if (fn(val[i]))
|
|
672
|
+
return true;
|
|
673
|
+
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
sum()
|
|
678
|
+
return this.reduce(function(accumulator, current) return accumulator + current;, 0);
|
|
679
|
+
|
|
680
|
+
average()
|
|
681
|
+
return this.sum() / this.length();
|
|
682
|
+
|
|
683
|
+
isArray()
|
|
684
|
+
return typeof(this.__INIT__) == "array";
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
class String extends BaseArray
|
|
688
|
+
{
|
|
689
|
+
constructor(x)
|
|
690
|
+
{
|
|
691
|
+
x = tostr(x);
|
|
692
|
+
super(x);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
set(x, y)
|
|
696
|
+
{
|
|
697
|
+
new result = "";
|
|
698
|
+
new val = this.__INIT__;
|
|
699
|
+
new length = len(val);
|
|
700
|
+
|
|
701
|
+
new i = 0;
|
|
702
|
+
for (i = 0; i < length; i++)
|
|
703
|
+
{
|
|
704
|
+
if (i == x)
|
|
705
|
+
result = concat(result, y)
|
|
706
|
+
else
|
|
707
|
+
result = concat(result, val[i]);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
this = result;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
concat(x)
|
|
714
|
+
this.__INIT__ = concat(this.__INIT__, x)
|
|
715
|
+
|
|
716
|
+
trimStart()
|
|
717
|
+
{
|
|
718
|
+
new val = this.__INIT__;
|
|
719
|
+
new result = "";
|
|
720
|
+
new length = len(val);
|
|
721
|
+
|
|
722
|
+
new i = 0;
|
|
723
|
+
new trimChar = true;
|
|
724
|
+
for (i = 0; i < length; i++)
|
|
725
|
+
{
|
|
726
|
+
new character = val[i];
|
|
727
|
+
|
|
728
|
+
if (character == " " && trimChar)
|
|
729
|
+
{
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
else
|
|
733
|
+
{
|
|
734
|
+
result = concat(result, character);
|
|
735
|
+
trimChar = false;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return result;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
trimEnd()
|
|
743
|
+
{
|
|
744
|
+
new val = this.__INIT__;
|
|
745
|
+
new length = len(val);
|
|
746
|
+
new end = length - 1;
|
|
747
|
+
|
|
748
|
+
while (end > 0 && val[end] == " ")
|
|
749
|
+
end = end - 1;
|
|
750
|
+
|
|
751
|
+
new result = "";
|
|
752
|
+
for (new i = 0; i <= end; i++)
|
|
753
|
+
result = concat(result, val[i]);
|
|
754
|
+
|
|
755
|
+
return result;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
trim()
|
|
759
|
+
{
|
|
760
|
+
new temp = this.trimEnd();
|
|
761
|
+
return String.trimStart(temp);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
replace(x, y)
|
|
765
|
+
{
|
|
766
|
+
new result = "";
|
|
767
|
+
new val = this.__INIT__;
|
|
768
|
+
new length = len(val);
|
|
769
|
+
new xLength = len(x);
|
|
770
|
+
|
|
771
|
+
new i, j = 0, 0;
|
|
772
|
+
new isSubstring = true;
|
|
773
|
+
while (i < length)
|
|
774
|
+
{
|
|
775
|
+
isSubstring = true;
|
|
776
|
+
for (j = 0; j < xLength; j++)
|
|
777
|
+
{
|
|
778
|
+
if (val[j + i] != x[j])
|
|
779
|
+
{
|
|
780
|
+
isSubstring = false;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (isSubstring)
|
|
786
|
+
{
|
|
787
|
+
result = concat(result, y);
|
|
788
|
+
i += xLength;
|
|
789
|
+
}
|
|
790
|
+
else
|
|
791
|
+
{
|
|
792
|
+
result = concat(result, val[i]);
|
|
793
|
+
i++;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
return result;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
split(x)
|
|
801
|
+
{
|
|
802
|
+
new result = [];
|
|
803
|
+
new chunk = "";
|
|
804
|
+
|
|
805
|
+
new val = this.__INIT__;
|
|
806
|
+
new length = len(val);
|
|
807
|
+
|
|
808
|
+
new xLength = len(x);
|
|
809
|
+
|
|
810
|
+
new i, j = 0, 0;
|
|
811
|
+
new isSeparator = true;
|
|
812
|
+
while (i < length)
|
|
813
|
+
{
|
|
814
|
+
isSeparator = true;
|
|
815
|
+
for (j = 0; j < xLength; j++)
|
|
816
|
+
{
|
|
817
|
+
if (val[j + i] != x[j])
|
|
818
|
+
{
|
|
819
|
+
isSeparator = false;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if (isSeparator)
|
|
825
|
+
{
|
|
826
|
+
push(result, chunk);
|
|
827
|
+
chunk = "";
|
|
828
|
+
i += xLength;
|
|
829
|
+
}
|
|
830
|
+
else
|
|
831
|
+
{
|
|
832
|
+
chunk = concat(chunk, val[i]);
|
|
833
|
+
i++;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
push(result, chunk);
|
|
838
|
+
|
|
839
|
+
return result;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
toLower()
|
|
843
|
+
{
|
|
844
|
+
new result = "";
|
|
845
|
+
|
|
846
|
+
new val = this.__INIT__;
|
|
847
|
+
new length = len(val);
|
|
848
|
+
|
|
849
|
+
new i = 0;
|
|
850
|
+
for (i = 0; i < length; i++)
|
|
851
|
+
{
|
|
852
|
+
new ascii = strascii(val[i]);
|
|
853
|
+
if (ascii < 65 || ascii > 90)
|
|
854
|
+
result = concat(result, val[i]);
|
|
855
|
+
else
|
|
856
|
+
result = concat(result, asciistr(ascii + 32));
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
return result;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
toUpper()
|
|
863
|
+
{
|
|
864
|
+
new result = "";
|
|
865
|
+
|
|
866
|
+
new val = this.__INIT__;
|
|
867
|
+
new length = len(val);
|
|
868
|
+
|
|
869
|
+
new i = 0;
|
|
870
|
+
for (i = 0; i < length; i++)
|
|
871
|
+
{
|
|
872
|
+
new ascii = strascii(val[i]);
|
|
873
|
+
if (ascii < 97 || ascii > 122)
|
|
874
|
+
result = concat(result, val[i]);
|
|
875
|
+
else
|
|
876
|
+
result = concat(result, asciistr(ascii - 32));
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
return result;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
slice(x, y)
|
|
883
|
+
{
|
|
884
|
+
if (typeof(x) != "float" && typeof(x) != "bigint")
|
|
885
|
+
TypeError.throw(concat('Parameter "x" of String function "slice" must be type Float or BigInt. But got "', x,'"'));
|
|
886
|
+
if (typeof(y) != "float" && typeof(y) != "bigint")
|
|
887
|
+
TypeError.throw(concat('Parameter "y" of String function "slice" must be type Float or BigInt. But got "', y,'"'));
|
|
888
|
+
|
|
889
|
+
new result = "";
|
|
890
|
+
|
|
891
|
+
new val = this.__INIT__ != undefined ? tostr(this.__INIT__) : tostr(this);
|
|
892
|
+
|
|
893
|
+
new length = len(val);
|
|
894
|
+
|
|
895
|
+
if (x < 0)
|
|
896
|
+
x = length + x;
|
|
897
|
+
if (y < 0)
|
|
898
|
+
y = length + y;
|
|
899
|
+
|
|
900
|
+
new i = 0;
|
|
901
|
+
for (i = x; i < y; i++)
|
|
902
|
+
{
|
|
903
|
+
result = concat(result, val[i]);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
return result;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
insert(i, y)
|
|
910
|
+
{
|
|
911
|
+
new result = "";
|
|
912
|
+
|
|
913
|
+
new val = this.__INIT__;
|
|
914
|
+
new length = len(val);
|
|
915
|
+
|
|
916
|
+
new j = 0;
|
|
917
|
+
for (j = 0; j < length; j++)
|
|
918
|
+
{
|
|
919
|
+
if (j == i)
|
|
920
|
+
result = concat(result, y);
|
|
921
|
+
|
|
922
|
+
result = concat(result, val[j]);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
this.__INIT__ = result;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
remove(i, x)
|
|
929
|
+
{
|
|
930
|
+
new result = "";
|
|
931
|
+
|
|
932
|
+
new val = this.__INIT__;
|
|
933
|
+
new length = len(val);
|
|
934
|
+
|
|
935
|
+
new j = 0;
|
|
936
|
+
for (j = 0; j < length; j++)
|
|
937
|
+
{
|
|
938
|
+
if (j >= i && j < i + x)
|
|
939
|
+
continue;
|
|
940
|
+
|
|
941
|
+
result = concat(result, val[j]);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
this.__INIT__ = result;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
format(x)
|
|
948
|
+
{
|
|
949
|
+
if (typeof(x) != "array")
|
|
950
|
+
TypeError.throw('Parameter x of function "format" should be type "Array". But got "', x, '"');
|
|
951
|
+
|
|
952
|
+
new result = "";
|
|
953
|
+
|
|
954
|
+
new val = this.__INIT__;
|
|
955
|
+
new length = len(val);
|
|
956
|
+
|
|
957
|
+
new xLength = len(x);
|
|
958
|
+
|
|
959
|
+
new i, j = 0, 0;
|
|
960
|
+
while (i < length)
|
|
961
|
+
{
|
|
962
|
+
if (concat(val[i], val[i + 1]) == "{}" && j < xLength)
|
|
963
|
+
{
|
|
964
|
+
result = concat(result, x[j]);
|
|
965
|
+
j++;
|
|
966
|
+
i += 2;
|
|
967
|
+
}
|
|
968
|
+
else if (concat(val[i], val[i + 1]) == "{}")
|
|
969
|
+
{
|
|
970
|
+
result = concat(result, "{}");
|
|
971
|
+
i += 2;
|
|
972
|
+
}
|
|
973
|
+
else
|
|
974
|
+
{
|
|
975
|
+
result = concat(result, val[i]);
|
|
976
|
+
i++;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
return result;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
startsWith(x)
|
|
984
|
+
return this.indexOf(x) == 0;
|
|
985
|
+
|
|
986
|
+
endsWith(x)
|
|
987
|
+
{
|
|
988
|
+
new val = this.__INIT__;
|
|
989
|
+
new length = len(val);
|
|
990
|
+
|
|
991
|
+
new sliced = this.slice(length - len(x), length);
|
|
992
|
+
|
|
993
|
+
return sliced == x;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
repeat(x)
|
|
997
|
+
{
|
|
998
|
+
new result = "";
|
|
999
|
+
new val = this.__INIT__;
|
|
1000
|
+
|
|
1001
|
+
new i = 0;
|
|
1002
|
+
for (i = 0; i < x; i++)
|
|
1003
|
+
result = concat(result, val);
|
|
1004
|
+
|
|
1005
|
+
return result;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
padStart(x, y)
|
|
1009
|
+
{
|
|
1010
|
+
new result = "";
|
|
1011
|
+
|
|
1012
|
+
new i = 0;
|
|
1013
|
+
for (i = 0; i < x - len(this.__INIT__); i++)
|
|
1014
|
+
result = concat(result, y);
|
|
1015
|
+
|
|
1016
|
+
return concat(result, this.__INIT__);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
padEnd(x, y)
|
|
1020
|
+
{
|
|
1021
|
+
new result = this.__INIT__;
|
|
1022
|
+
|
|
1023
|
+
new i = 0;
|
|
1024
|
+
for (i = 0; i < x - len(this.__INIT__); i++)
|
|
1025
|
+
result = concat(result, y);
|
|
1026
|
+
|
|
1027
|
+
return result;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
isAlpha()
|
|
1031
|
+
{
|
|
1032
|
+
new val = this.__INIT__;
|
|
1033
|
+
new length = len(val);
|
|
1034
|
+
|
|
1035
|
+
new i = 0;
|
|
1036
|
+
for (i = 0; i < length; i++)
|
|
1037
|
+
{
|
|
1038
|
+
if
|
|
1039
|
+
(
|
|
1040
|
+
!(
|
|
1041
|
+
(strascii(val[i]) >= 65 && strascii(val[i]) <= 90) || # A-Z
|
|
1042
|
+
(strascii(val[i]) >= 97 && strascii(val[i]) <= 122) # a-z
|
|
1043
|
+
)
|
|
1044
|
+
)
|
|
1045
|
+
return false;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
isAlphaNumeric()
|
|
1052
|
+
{
|
|
1053
|
+
new val = this.__INIT__;
|
|
1054
|
+
new length = len(val);
|
|
1055
|
+
|
|
1056
|
+
new i = 0;
|
|
1057
|
+
for (i = 0; i < length; i++)
|
|
1058
|
+
{
|
|
1059
|
+
if
|
|
1060
|
+
(
|
|
1061
|
+
!(
|
|
1062
|
+
(strascii(val[i]) >= 65 && strascii(val[i]) <= 90) || # A-Z
|
|
1063
|
+
(strascii(val[i]) >= 97 && strascii(val[i]) <= 122) || # a-z
|
|
1064
|
+
(strascii(val[i]) >= 48 && strascii(val[i]) <= 57) # 1 - 9
|
|
1065
|
+
)
|
|
1066
|
+
)
|
|
1067
|
+
return false;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
return true;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
includes(x)
|
|
1074
|
+
return this.indexOf(x) > -1;
|
|
1075
|
+
|
|
1076
|
+
count(x)
|
|
1077
|
+
{
|
|
1078
|
+
new val = this.__INIT__;
|
|
1079
|
+
new length = len(val);
|
|
1080
|
+
|
|
1081
|
+
new xLength = len(x);
|
|
1082
|
+
new isX = true;
|
|
1083
|
+
|
|
1084
|
+
new i, j = 0, 0;
|
|
1085
|
+
new count = 0;
|
|
1086
|
+
while (i < length)
|
|
1087
|
+
{
|
|
1088
|
+
isX = true;
|
|
1089
|
+
for (j = 0; j < xLength; j++)
|
|
1090
|
+
{
|
|
1091
|
+
if (val[j + i] != x[j])
|
|
1092
|
+
{
|
|
1093
|
+
isX = false;
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
if (isX)
|
|
1099
|
+
{
|
|
1100
|
+
count++;
|
|
1101
|
+
i += xLength;
|
|
1102
|
+
}
|
|
1103
|
+
else
|
|
1104
|
+
i++;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
return count;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
reverse()
|
|
1111
|
+
{
|
|
1112
|
+
new result = "";
|
|
1113
|
+
|
|
1114
|
+
new val = this.__INIT__;
|
|
1115
|
+
new length = len(val);
|
|
1116
|
+
|
|
1117
|
+
new i = 0;
|
|
1118
|
+
for (i = length-1; i >= 0; i--)
|
|
1119
|
+
result = concat(result, val[i]);
|
|
1120
|
+
|
|
1121
|
+
return result;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
isNumeric()
|
|
1125
|
+
return strascii(this.__INIT__) <= 9;
|
|
1126
|
+
|
|
1127
|
+
capitalize()
|
|
1128
|
+
{
|
|
1129
|
+
new first = inst String(this.slice(0, 1));
|
|
1130
|
+
new rest = inst String(this.slice(1, len(this.__INIT__)));
|
|
1131
|
+
return concat(first.toUpper(), rest.toLower());
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
words()
|
|
1135
|
+
return this.split(" ");
|
|
1136
|
+
|
|
1137
|
+
isWhitespace()
|
|
1138
|
+
{
|
|
1139
|
+
new val = this.__INIT__;
|
|
1140
|
+
new length = len(val);
|
|
1141
|
+
|
|
1142
|
+
new i = 0;
|
|
1143
|
+
for (i = 0; i < length; i++)
|
|
1144
|
+
{
|
|
1145
|
+
if
|
|
1146
|
+
(
|
|
1147
|
+
!(
|
|
1148
|
+
val[i] == "\t" ||
|
|
1149
|
+
val[i] == "\n" ||
|
|
1150
|
+
val[i] == " "
|
|
1151
|
+
)
|
|
1152
|
+
)
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
toArray()
|
|
1160
|
+
{
|
|
1161
|
+
new result = [];
|
|
1162
|
+
|
|
1163
|
+
new val = this.__INIT__;
|
|
1164
|
+
new length = len(val);
|
|
1165
|
+
|
|
1166
|
+
new i = 0;
|
|
1167
|
+
for (i = 0; i < length; i++)
|
|
1168
|
+
push(result, val[i]);
|
|
1169
|
+
|
|
1170
|
+
return result;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
wrap(x, y)
|
|
1174
|
+
return concat(x, this.__INIT__, y);
|
|
1175
|
+
|
|
1176
|
+
isString()
|
|
1177
|
+
return typeof(this.__INIT__) == "string";
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
class Number
|
|
1181
|
+
{
|
|
1182
|
+
constructor(x)
|
|
1183
|
+
this.__INIT__ = x;
|
|
1184
|
+
|
|
1185
|
+
toString()
|
|
1186
|
+
return tostr(this.__INIT__);
|
|
1187
|
+
|
|
1188
|
+
toBigInt()
|
|
1189
|
+
return tobigint(this.__INIT__);
|
|
1190
|
+
|
|
1191
|
+
valueOf()
|
|
1192
|
+
return this.__INIT__;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
class Float extends Number
|
|
1196
|
+
{
|
|
1197
|
+
constructor(x)
|
|
1198
|
+
super(tofloat(x));
|
|
1199
|
+
|
|
1200
|
+
abs()
|
|
1201
|
+
{
|
|
1202
|
+
new val = this.__INIT__;
|
|
1203
|
+
if (val < 0)
|
|
1204
|
+
return inst Float(-val);
|
|
1205
|
+
return inst Float(val);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
class BigInt extends Number
|
|
1210
|
+
{
|
|
1211
|
+
constructor(x)
|
|
1212
|
+
super(tobigint(x));
|
|
1213
|
+
|
|
1214
|
+
abs()
|
|
1215
|
+
{
|
|
1216
|
+
new val = this.__INIT__;
|
|
1217
|
+
if (val < 0)
|
|
1218
|
+
return inst BigInt(-val);
|
|
1219
|
+
return inst BigInt(val);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
const unwrap = function(x) return typeof(x) == "object" ? x.__INIT__ : x;
|
|
1224
|
+
Float.isFloat = function(x) return typeof(unwrap(x)) == "float";
|
|
1225
|
+
Float.toFloat = function(x) return tofloat(unwrap(x));
|
|
1226
|
+
Float.toBigInt = function(x) return tobigint(unwrap(x));
|
|
1227
|
+
Float.toString = function(x) return tostr(unwrap(x));
|
|
1228
|
+
|
|
1229
|
+
BigInt.isBigInt = function(x) return typeof(unwrap(x)) == "bigint";
|
|
1230
|
+
BigInt.toFloat = function(x) return tofloat(unwrap(x));
|
|
1231
|
+
BigInt.toBigInt = function(x) return tobigint(unwrap(x));
|
|
1232
|
+
BigInt.toString = function(x) return tostr(unwrap(x));
|