-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.json
3236 lines (3236 loc) · 143 KB
/
source.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
[
{
"label": "Infinity",
"title": "Infinity:number",
"description": "#### Infinity:number\n\nThe name `Infinity` refers to the special number value `Infinity`. See [ECMAScript Specification, Section 4.3.23](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-value-properties-of-the-global-object-infinity)",
"meta": "const"
},
{
"label": "math_E",
"title": "math_E:number",
"description": "#### math\\_E:number\n\nThe Number value for e, Euler's number, which is approximately 2.718281828459045.",
"meta": "const"
},
{
"label": "math_LN2",
"title": "math_LN2:number",
"description": "#### math\\_LN2:number\n\nThe Number value for the natural logarithm of 2, which is approximately 0.6931471805599453.",
"meta": "const"
},
{
"label": "math_LN10",
"title": "math_LN10:number",
"description": "#### math\\_LN10:number\n\nThe Number value for the natural logarithm of 10, which is approximately 2.302585092994046.",
"meta": "const"
},
{
"label": "math_LOG2E",
"title": "math_LOG2E:number",
"description": "#### math\\_LOG2E:number\n\nThe Number value for the base-2 logarithm of eℝ, the base of the natural logarithms; this value is approximately 1.4426950408889634.\n\nNOTE: The value of math\\_LOG2E is approximately the reciprocal of the value of math\\_LN2.",
"meta": "const"
},
{
"label": "math_LOG10E",
"title": "math_LOG10E:number",
"description": "#### math\\_LOG10E:number\n\nThe Number value for the base-10 logarithm of e, the base of the natural logarithms; this value is approximately 0.4342944819032518.\n\nNOTE: The value of math\\_LOG10E is approximately the reciprocal of the value of math\\_LN10.",
"meta": "const"
},
{
"label": "math_PI",
"title": "math_PI:number",
"description": "#### math\\_PI:number\n\nThe Number value for π, the ratio of the circumference of a circle to its diameter, which is approximately 3.1415926535897932.",
"meta": "const"
},
{
"label": "math_SQRT1_2",
"title": "math_SQRT1_2:number",
"description": "#### math\\_SQRT1\\_2:number\n\nThe Number value for the square root of 0.5, which is approximately 0.7071067811865476.\n\nNOTE: The value of math\\_SQRT1\\_2 is approximately the reciprocal of the value of math\\_SQRT2.",
"meta": "const"
},
{
"label": "math_SQRT2",
"title": "math_SQRT2:number",
"description": "#### math\\_SQRT2:number\n\nThe Number value for the square root of 2, which is approximately 1.4142135623730951.",
"meta": "const"
},
{
"label": "NaN",
"title": "NaN:number",
"description": "#### NaN:number\n\nThe name `NaN` refers to the special number value `NaN` (\"not a number\"). Note that `NaN` is a number, as specified by `is_number`. See [ECMAScript Specification, Section 4.3.24](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-value-properties-of-the-global-object-nan)",
"meta": "const"
},
{
"label": "undefined",
"title": "undefined:undefined",
"description": "#### undefined:undefined\n\nThe name `undefined` refers to the special value `undefined`. See also [textbook explanation in section 4.1.1](https://sourceacademy.org/sicpjs/4.1.1#h5).",
"meta": "const"
},
{
"label": "arity",
"title": "arity(f) → {number}",
"description": "#### arity(f) → {number}\n\nReturns the number of parameters the given function `f` expects, excluding the rest parameter.",
"meta": "func",
"parameters": [
"f"
]
},
{
"label": "char_at",
"title": "char_at(s, i) → {string}",
"description": "#### char\\_at(s, i) → {string}\n\nTakes a string `s` as first argument and a nonnegative integer `i` as second argument. If `i` is less than the length of `s`, this function returns a one-character string that contains the character of `s` at position `i`, counting from 0. If `i` is larger than or equal to the length of `s`, this function returns `undefined`.",
"meta": "func",
"parameters": [
"s",
"i"
]
},
{
"label": "display",
"title": "display(v, s) → {value}",
"description": "#### display(v, s) → {value}\n\nOptional second argument. If present, displays the given string `s`, followed by a space character, followed by the value `v` in the console. If second argument not present, just displays the value `v` in the console. The notation used for the display of values is consistent with [JSON](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf), but also displays `undefined`, `NaN`, `Infinity`, and function objects.",
"meta": "func",
"parameters": [
"v",
"s"
],
"optional_params": [
"s"
]
},
{
"label": "error",
"title": "error(v, s)",
"description": "#### error(v, s)\n\nOptional second argument. If present, displays the given string `s`, followed by a space character, followed by the value `v` in the console with error flag. If second argument not present, just displays the value `v` in the console with error flag. The evaluation of any call of `error` aborts the running program immediately. The notation used for the display of values is consistent with [JSON](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf), but also displays `undefined`, `NaN`, `Infinity`, and function objects.",
"meta": "func",
"parameters": [
"v",
"s"
],
"optional_params": [
"s"
]
},
{
"label": "get_time",
"title": "get_time() → {number}",
"description": "#### get\\_time() → {number}\n\nReturns number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. See also [textbook example](https://sourceacademy.org/sicpjs/1.2.6#ex-1.21).",
"meta": "func",
"parameters": []
},
{
"label": "is_boolean",
"title": "is_boolean(v) → {boolean}",
"description": "#### is\\_boolean(v) → {boolean}\n\nchecks whether a given value is a boolean",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_function",
"title": "is_function(v) → {boolean}",
"description": "#### is\\_function(v) → {boolean}\n\nchecks whether a given value is a function",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_number",
"title": "is_number(v) → {boolean}",
"description": "#### is\\_number(v) → {boolean}\n\nchecks whether a given value is a number. See also [textbook example](https://sourceacademy.org/sicpjs/2.3.2).",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_string",
"title": "is_string(v) → {boolean}",
"description": "#### is\\_string(v) → {boolean}\n\nchecks whether a given value is a string. See also [textbook example](https://sourceacademy.org/sicpjs/2.3.2).",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_undefined",
"title": "is_undefined(v) → {boolean}",
"description": "#### is\\_undefined(v) → {boolean}\n\nchecks whether a given value is the special value `undefined`",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "math_abs",
"title": "math_abs(x) → {number}",
"description": "#### math\\_abs(x) → {number}\n\ncomputes the absolute value of x; the result has the same magnitude as `x` but has positive sign.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_acos",
"title": "math_acos(x) → {number}",
"description": "#### math\\_acos(x) → {number}\n\ncomputes the arc cosine of `x`. The result is expressed in radians and ranges from +0 to +π.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_acosh",
"title": "math_acosh(x) → {number}",
"description": "#### math\\_acosh(x) → {number}\n\ncomputes the inverse hyperbolic cosine of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_asin",
"title": "math_asin(x) → {number}",
"description": "#### math\\_asin(x) → {number}\n\ncomputes the arc sine of `x`. The result is expressed in radians and ranges from -π / 2 to +π / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_asinh",
"title": "math_asinh(x) → {number}",
"description": "#### math\\_asinh(x) → {number}\n\ncomputes the inverse hyperbolic sine of `x`. The result is expressed in radians and ranges from -π / 2 to +π / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_atan",
"title": "math_atan(x) → {number}",
"description": "#### math\\_atan(x) → {number}\n\ncomputes the arc tangent of `x`. The result is expressed in radians and ranges from -π / 2 to +π / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_atan2",
"title": "math_atan2(y, x) → {number}",
"description": "#### math\\_atan2(y, x) → {number}\n\ncomputes the arc tangent of the quotient `y` / `x` of the arguments `y` and `x`, where the signs of `y` and `x` are used to determine the quadrant of the result. Note that it is intentional and traditional for the two-argument arc tangent function that the argument named `y` be first and the argument named `x` be second. The result is expressed in radians and ranges from -π to +π.",
"meta": "func",
"parameters": [
"y",
"x"
]
},
{
"label": "math_atanh",
"title": "math_atanh(x) → {number}",
"description": "#### math\\_atanh(x) → {number}\n\ncomputes the inverse hyperbolic tangent of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_cbrt",
"title": "math_cbrt(x) → {number}",
"description": "#### math\\_cbrt(x) → {number}\n\ncomputes the cube root of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_ceil",
"title": "math_ceil(x) → {number}",
"description": "#### math\\_ceil(x) → {number}\n\ncomputes the smallest (closest to -∞) Number value that is not less than `x` and is an integer. If `x` is already an integer, the result is `x`. The value of math\\_ceil(x) is the same as the value of -math\\_floor(-x).",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_clz32",
"title": "math_clz32(n) → {number}",
"description": "#### math\\_clz32(n) → {number}\n\nWhen math\\_clz32 is called with one argument `x`, the following steps are taken: Let n be ToUint32(x). Let p be the number of leading zero bits in the 32-bit binary representation of n. Return p.\n\nNOTE: \nIf n is 0, p will be 32. If the most significant bit of the 32-bit binary encoding of n is 1, p will be 0.",
"meta": "func",
"parameters": [
"n"
]
},
{
"label": "math_cos",
"title": "math_cos(x) → {number}",
"description": "#### math\\_cos(x) → {number}\n\nComputes the cosine of `x`. The argument is expressed in radians.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_cosh",
"title": "math_cosh(x) → {number}",
"description": "#### math\\_cosh(x) → {number}\n\ncomputes the hyperbolic cosine of `x`.\n\nNOTE: The value of cosh(x) is the same as (exp(x) + exp(-x)) / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_exp",
"title": "math_exp(x) → {number}",
"description": "#### math\\_exp(x) → {number}\n\ncomputes the exponential function of `x` (e raised to the power of `x`, where e is the base of the natural logarithms).",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_expm1",
"title": "math_expm1(x) → {number}",
"description": "#### math\\_expm1(x) → {number}\n\ncomputes subtracting 1 from the exponential function of `x` (e raised to the power of `x`, where e is the base of the natural logarithms). The result is computed in a way that is accurate even when the value of `x` is close to 0.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_floor",
"title": "math_floor(x) → {number}",
"description": "#### math\\_floor(x) → {number}\n\ncomputes the greatest (closest to +∞) Number value that is not greater than `x` and is an integer. \nIf `x` is already an integer, the result is `x`.\n\nNOTE: The value of math\\_floor(x) is the same as the value of -math\\_ceil(-x).",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_fround",
"title": "math_fround(x) → {number}",
"description": "#### math\\_fround(x) → {number}\n\nWhen math\\_fround is called with argument `x`, the following steps are taken:\n\n1. If `x` is NaN, return NaN.\n2. If `x` is one of +0, -0, +∞, -∞, return `x`.\n3. Let x32 be the result of converting `x` to a value in IEEE 754-2008 binary32 format using roundTiesToEven mode.\n4. Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.\n5. Return the ECMAScript Number value corresponding to x64.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_hypot",
"title": "math_hypot() → {number}",
"description": "#### math\\_hypot() → {number}\n\ncomputes the square root of the sum of squares of its arguments. \nIf no arguments are passed, the result is +0.",
"meta": "func",
"parameters": []
},
{
"label": "math_imul",
"title": "math_imul(x, x) → {number}",
"description": "#### math\\_imul(x, x) → {number}\n\nWhen math\\_imul is called with arguments `x` and `y`, the following steps are taken:\n\n1. Let a be ToUint32(x).\n2. Let b be ToUint32(y).\n3. Let product be (a × b) modulo 232.\n4. If product ≥ 231, return product - 232; otherwise return product.",
"meta": "func",
"parameters": [
"x",
"x"
]
},
{
"label": "math_log",
"title": "math_log(x) → {number}",
"description": "#### math\\_log(x) → {number}\n\nComputes the natural logarithm of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_log1p",
"title": "math_log1p(x) → {number}",
"description": "#### math\\_log1p(x) → {number}\n\ncomputes the natural logarithm of 1 + `x`. The result is computed in a way that is accurate even when the value of `x` is close to zero.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_log2",
"title": "math_log2(x) → {number}",
"description": "#### math\\_log2(x) → {number}\n\ncomputes the base 2 logarithm of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_log10",
"title": "math_log10(x) → {number}",
"description": "#### math\\_log10(x) → {number}\n\ncomputes the base 10 logarithm of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_max",
"title": "math_max() → {number}",
"description": "#### math\\_max() → {number}\n\nGiven zero or more numbers, returns the largest of them. \nIf no arguments are given, the result is -∞. \nIf any value is NaN, the result is NaN. The comparison of values to determine the largest value is done using the Abstract Relational Comparison algorithm except that +0 is considered to be larger than -0.",
"meta": "func",
"parameters": []
},
{
"label": "math_min",
"title": "math_min() → {number}",
"description": "#### math\\_min() → {number}\n\nGiven zero or more arguments, returns the smallest of them. \nIf no arguments are given, the result is +∞. \nIf any value is NaN, the result is NaN. The comparison of values to determine the smallest value is done using the Abstract Relational Comparison algorithm except that +0 is considered to be larger than -0.",
"meta": "func",
"parameters": []
},
{
"label": "math_pow",
"title": "math_pow(base, exponent) → {number}",
"description": "#### math\\_pow(base, exponent) → {number}\n\nComputes the result of raising base to the power of exponent.",
"meta": "func",
"parameters": [
"base",
"exponent"
]
},
{
"label": "math_random",
"title": "math_random() → {number}",
"description": "#### math\\_random() → {number}\n\nReturns a number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy. This function takes no arguments. Each math\\_random function created for distinct realms must produce a distinct sequence of values from successive calls.",
"meta": "func",
"parameters": []
},
{
"label": "math_round",
"title": "math_round(x) → {number}",
"description": "#### math\\_round(x) → {number}\n\nReturns the number value that is closest to `x` and is an integer. \nIf two integers are equally close to `x`, then the result is the Number value that is closer to +∞. If `x` is already an integer, the result is `x`. NOTE 1: math\\_round(3.5) returns 4, but math\\_round(-3.5) returns -3.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_sign",
"title": "math_sign(x) → {number}",
"description": "#### math\\_sign(x) → {number}\n\nComputes the sign of `x`, indicating whether `x` is positive, negative, or zero.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_sin",
"title": "math_sin(x) → {number}",
"description": "#### math\\_sin(x) → {number}\n\nComputes the sine of `x`. The argument is expressed in radians.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_sinh",
"title": "math_sinh(x) → {number}",
"description": "#### math\\_sinh(x) → {number}\n\nComputes the hyperbolic sine of `x`.\n\nNOTE: The value of sinh(x) is the same as (exp(x) - exp(-x)) / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_sqrt",
"title": "math_sqrt(x) → {number}",
"description": "#### math\\_sqrt(x) → {number}\n\nComputes the square root of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_tan",
"title": "math_tan(x) → {number}",
"description": "#### math\\_tan(x) → {number}\n\nComputes the tangent of `x`. The argument is expressed in radians.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_tanh",
"title": "math_tanh(x) → {number}",
"description": "#### math\\_tanh(x) → {number}\n\nComputes the hyperbolic tangent of `x`.\n\nNOTE: The value of `math_tanh(x)` is the same as `(exp(x) - exp(-x))/(exp(x) + exp(-x))`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_trunc",
"title": "math_trunc(x) → {number}",
"description": "#### math\\_trunc(x) → {number}\n\nComputes the integral part of the number `x`, removing any fractional digits.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "parse_int",
"title": "parse_int(s, i) → {number}",
"description": "#### parse\\_int(s, i) → {number}\n\nInterprets a given string `s` as an integer, using the positive integer `i` as radix, and returns the respective value. \nExamples: `parse_int(\"909\", 10)` returns the number `909`, and `parse_int(\"-1111\", 2)` returns the number `-15`. \nSee [ECMAScript Specification, Section 18.2.5](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-parseint-string-radix) for details.",
"meta": "func",
"parameters": [
"s",
"i"
]
},
{
"label": "prompt",
"title": "prompt(s) → {string}",
"description": "#### prompt(s) → {string}\n\nPops up a window that displays the string `s`, provides an input line for the user to enter a text, a `Cancel` button and an `OK` button. The call of `prompt` suspends execution of the program until one of the two buttons is pressed. If the `OK` button is pressed, `prompt` returns the entered text as a string. If the `Cancel` button is pressed, `prompt` returns a non-string value.",
"meta": "func",
"parameters": [
"s"
]
},
{
"label": "stringify",
"title": "stringify(v) → {string}",
"description": "#### stringify(v) → {string}\n\nreturns a string that represents the value `v`, using a notation that is is consistent with [JSON](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf), but also displays `undefined`, `NaN`, `Infinity`, and function objects. See also [textbook example](https://sourceacademy.org/sicpjs/3.3.5).",
"meta": "func",
"parameters": [
"v"
]
}
],
[
{
"label": "Infinity",
"title": "Infinity:number",
"description": "#### Infinity:number\n\nThe name `Infinity` refers to the special number value `Infinity`. See [ECMAScript Specification, Section 4.3.23](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-value-properties-of-the-global-object-infinity)",
"meta": "const"
},
{
"label": "math_E",
"title": "math_E:number",
"description": "#### math\\_E:number\n\nThe Number value for e, Euler's number, which is approximately 2.718281828459045.",
"meta": "const"
},
{
"label": "math_LN2",
"title": "math_LN2:number",
"description": "#### math\\_LN2:number\n\nThe Number value for the natural logarithm of 2, which is approximately 0.6931471805599453.",
"meta": "const"
},
{
"label": "math_LN10",
"title": "math_LN10:number",
"description": "#### math\\_LN10:number\n\nThe Number value for the natural logarithm of 10, which is approximately 2.302585092994046.",
"meta": "const"
},
{
"label": "math_LOG2E",
"title": "math_LOG2E:number",
"description": "#### math\\_LOG2E:number\n\nThe Number value for the base-2 logarithm of eℝ, the base of the natural logarithms; this value is approximately 1.4426950408889634.\n\nNOTE: The value of math\\_LOG2E is approximately the reciprocal of the value of math\\_LN2.",
"meta": "const"
},
{
"label": "math_LOG10E",
"title": "math_LOG10E:number",
"description": "#### math\\_LOG10E:number\n\nThe Number value for the base-10 logarithm of e, the base of the natural logarithms; this value is approximately 0.4342944819032518.\n\nNOTE: The value of math\\_LOG10E is approximately the reciprocal of the value of math\\_LN10.",
"meta": "const"
},
{
"label": "math_PI",
"title": "math_PI:number",
"description": "#### math\\_PI:number\n\nThe Number value for π, the ratio of the circumference of a circle to its diameter, which is approximately 3.1415926535897932.",
"meta": "const"
},
{
"label": "math_SQRT1_2",
"title": "math_SQRT1_2:number",
"description": "#### math\\_SQRT1\\_2:number\n\nThe Number value for the square root of 0.5, which is approximately 0.7071067811865476.\n\nNOTE: The value of math\\_SQRT1\\_2 is approximately the reciprocal of the value of math\\_SQRT2.",
"meta": "const"
},
{
"label": "math_SQRT2",
"title": "math_SQRT2:number",
"description": "#### math\\_SQRT2:number\n\nThe Number value for the square root of 2, which is approximately 1.4142135623730951.",
"meta": "const"
},
{
"label": "NaN",
"title": "NaN:number",
"description": "#### NaN:number\n\nThe name `NaN` refers to the special number value `NaN` (\"not a number\"). Note that `NaN` is a number, as specified by `is_number`. See [ECMAScript Specification, Section 4.3.24](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-value-properties-of-the-global-object-nan)",
"meta": "const"
},
{
"label": "undefined",
"title": "undefined:undefined",
"description": "#### undefined:undefined\n\nThe name `undefined` refers to the special value `undefined`. See also [textbook explanation in section 4.1.1](https://sourceacademy.org/sicpjs/4.1.1#h5).",
"meta": "const"
},
{
"label": "__access_export__",
"title": "__access_export__(exports, lookup_name) → {value}",
"description": "#### \\_\\_access\\_export\\_\\_(exports, lookup\\_name) → {value}\n\nSearches for the specified name in the data structure of exported names. The data structure is a pair where the head element is the default export and the tail element is a list of pairs where each pair is a mapping from the exported name to the value being exported. If the lookup name is \"default\", the default export is returned instead of a named export. If the name does not exist, `undefined` is returned.",
"meta": "func",
"parameters": [
"exports",
"lookup_name"
]
},
{
"label": "__access_named_export__",
"title": "__access_named_export__(named_exports, lookup_name) → {value}",
"description": "#### \\_\\_access\\_named\\_export\\_\\_(named\\_exports, lookup\\_name) → {value}\n\nSearches for the specified name in the data structure of exported names. The data structure is a list of pairs where each pair is a mapping from the exported name to the value being exported. If the name does not exist, `undefined` is returned.",
"meta": "func",
"parameters": [
"named_exports",
"lookup_name"
]
},
{
"label": "accumulate",
"title": "accumulate(f, initial, xs) → {value}",
"description": "#### accumulate(f, initial, xs) → {value}\n\nApplies binary function `f` to the elements of `xs` from right-to-left order, first applying `f` to the last element and the value `initial`, resulting in `r`1, then to the second-last element and `r`1, resulting in `r`2, etc, and finally to the first element and `r`n-1, where `n` is the length of the list. Thus, `accumulate(f,zero,list(1,2,3))` results in `f(1, f(2, f(3, zero)))`. Iterative process; time: `Theta(n)` (apart from `f`), space: `Theta(n)` (apart from `f`), where `n` is the length of `xs`.",
"meta": "func",
"parameters": [
"(x, y) => ",
"initial",
"xs"
]
},
{
"label": "append",
"title": "append(xs, ys) → {list}",
"description": "#### append(xs, ys) → {list}\n\nReturns a list that results from appending the list `ys` to the list `xs`. Iterative process; time: `Theta(n)`, space: `Theta(n)`, where `n` is the length of `xs`. In the result, null at the end of the first argument list is replaced by the second argument, regardless what the second argument consists of.",
"meta": "func",
"parameters": [
"xs",
"ys"
]
},
{
"label": "arity",
"title": "arity(f) → {number}",
"description": "#### arity(f) → {number}\n\nReturns the number of parameters the given function `f` expects, excluding the rest parameter.",
"meta": "func",
"parameters": [
"f"
]
},
{
"label": "build_list",
"title": "build_list(f, n) → {list}",
"description": "#### build\\_list(f, n) → {list}\n\nMakes a list with `n` elements by applying the unary function `f` to the numbers 0 to `n - 1`, assumed to be a nonnegative integer. Iterative process; time: `Theta(n)` (apart from `f`), space: `Theta(n)` (apart from `f`).",
"meta": "func",
"parameters": [
"x => ",
"n"
]
},
{
"label": "char_at",
"title": "char_at(s, i) → {string}",
"description": "#### char\\_at(s, i) → {string}\n\nTakes a string `s` as first argument and a nonnegative integer `i` as second argument. If `i` is less than the length of `s`, this function returns a one-character string that contains the character of `s` at position `i`, counting from 0. If `i` is larger than or equal to the length of `s`, this function returns `undefined`.",
"meta": "func",
"parameters": [
"s",
"i"
]
},
{
"label": "display",
"title": "display(v, s) → {value}",
"description": "#### display(v, s) → {value}\n\nOptional second argument. If present, displays the given string `s`, followed by a space character, followed by the value `v` in the console. If second argument not present, just displays the value `v` in the console. The notation used for the display of values is consistent with [JSON](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf), but also displays `undefined`, `NaN`, `Infinity`, and function objects.",
"meta": "func",
"parameters": [
"v",
"s"
],
"optional_params": [
"s"
]
},
{
"label": "display_list",
"title": "display_list(xs, s) → {value}",
"description": "#### display\\_list(xs, s) → {value}\n\nOptional second argument. Similar to `display`, but formats well-formed lists nicely if detected; time, space: `Theta(n)`, where `n` is the total number of data structures such as pairs in `x`.",
"meta": "func",
"parameters": [
"xs",
"s"
],
"optional_params": [
"s"
]
},
{
"label": "draw_data",
"title": "draw_data() → {value}",
"description": "#### draw\\_data() → {value}\n\nvisualizes the arguments in a separate drawing area in the Source Academy using box-and-pointer diagrams; time, space: `Theta(n)`, where `n` is the total number of data structures such as pairs in the arguments.",
"meta": "func",
"parameters": [],
"hasRestElement": true
},
{
"label": "enum_list",
"title": "enum_list(start, end) → {list}",
"description": "#### enum\\_list(start, end) → {list}\n\nReturns a list that enumerates numbers starting from `start` using a step size of 1, until the number exceeds (`>`) `end`. Iterative process; time: `Theta(n)`, space: `Theta(n)`, where `n` is `end - start`.",
"meta": "func",
"parameters": [
"start",
"end"
]
},
{
"label": "equal",
"title": "equal(x, y) → {boolean}",
"description": "#### equal(x, y) → {boolean}\n\nReturns `true` if both have the same structure with respect to `pair`, and identical values at corresponding leave positions (places that are not themselves pairs), and `false` otherwise. For the \"identical\", the values need to have the same type, otherwise the result is `false`. If corresponding leaves are boolean values, these values need to be the same. If both are `undefined` or both are `null`, the result is `true`. Otherwise they are compared with `===` (using the definition of `===` in the respective Source language in use). Time, space: `Theta(n)`, where `n` is the total number of data structures such as pairs in `x` and `y`.",
"meta": "func",
"parameters": [
"x",
"y"
]
},
{
"label": "error",
"title": "error(v, s)",
"description": "#### error(v, s)\n\nOptional second argument. If present, displays the given string `s`, followed by a space character, followed by the value `v` in the console with error flag. If second argument not present, just displays the value `v` in the console with error flag. The evaluation of any call of `error` aborts the running program immediately. The notation used for the display of values is consistent with [JSON](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf), but also displays `undefined`, `NaN`, `Infinity`, and function objects.",
"meta": "func",
"parameters": [
"v",
"s"
],
"optional_params": [
"s"
]
},
{
"label": "filter",
"title": "filter(pred, xs) → {list}",
"description": "#### filter(pred, xs) → {list}\n\nReturns a list that contains only those elements for which the one-argument function `pred` returns `true`. Iterative process; time: `Theta(n)` (apart from `pred`), space: `Theta(n)` (apart from `pred`), where `n` is the length of `xs`.",
"meta": "func",
"parameters": [
"x => ",
"xs"
]
},
{
"label": "for_each",
"title": "for_each(f, xs) → {boolean}",
"description": "#### for\\_each(f, xs) → {boolean}\n\nApplies unary function `f` to every element of the list `xs`. Iterative process; time: `Theta(n)` (apart from `f`), space: `Theta(1)` (apart from `f`), where `n` is the length of `xs`. `f` is applied element-by-element: `for_each(fun, list(1, 2))` results in the calls `fun(1)` and `fun(2)`.",
"meta": "func",
"parameters": [
"x => ",
"xs"
]
},
{
"label": "get_time",
"title": "get_time() → {number}",
"description": "#### get\\_time() → {number}\n\nReturns number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. See also [textbook example](https://sourceacademy.org/sicpjs/1.2.6#ex-1.21).",
"meta": "func",
"parameters": []
},
{
"label": "head",
"title": "head(p) → {value}",
"description": "#### head(p) → {value}\n\n\\*\\*primitive\\*\\*; returns head (first component) of given pair `p`; time: `Theta(1)Theta(1)`.",
"meta": "func",
"parameters": [
"p"
]
},
{
"label": "is_boolean",
"title": "is_boolean(v) → {boolean}",
"description": "#### is\\_boolean(v) → {boolean}\n\nchecks whether a given value is a boolean",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_function",
"title": "is_function(v) → {boolean}",
"description": "#### is\\_function(v) → {boolean}\n\nchecks whether a given value is a function",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_list",
"title": "is_list(xs) → {xs}",
"description": "#### is\\_list(xs) → {xs}\n\n\\*\\*primitive\\*\\*; returns `true` if `xs` is a list as defined in the textbook, and `false` otherwise. Iterative process; time: `Theta(n)`, space: `Theta(1)`, where `n` is the length of the chain of `tail` operations that can be applied to `xs`. `is_list` recurses down the list and checks that it ends with the empty list null",
"meta": "func",
"parameters": [
"xs"
]
},
{
"label": "is_null",
"title": "is_null(x) → {boolean}",
"description": "#### is\\_null(x) → {boolean}\n\n\\*\\*primitive\\*\\*; returns `true` if `x` is the empty list `null`, and `false` otherwise; time: `Theta(1)Theta(1)`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "is_number",
"title": "is_number(v) → {boolean}",
"description": "#### is\\_number(v) → {boolean}\n\nchecks whether a given value is a number. See also [textbook example](https://sourceacademy.org/sicpjs/2.3.2).",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_pair",
"title": "is_pair(x) → {boolean}",
"description": "#### is\\_pair(x) → {boolean}\n\n\\*\\*primitive\\*\\*; returns `true` if `x` is a pair and false otherwise; time: `Theta(1)Theta(1)`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "is_string",
"title": "is_string(v) → {boolean}",
"description": "#### is\\_string(v) → {boolean}\n\nchecks whether a given value is a string. See also [textbook example](https://sourceacademy.org/sicpjs/2.3.2).",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "is_undefined",
"title": "is_undefined(v) → {boolean}",
"description": "#### is\\_undefined(v) → {boolean}\n\nchecks whether a given value is the special value `undefined`",
"meta": "func",
"parameters": [
"v"
]
},
{
"label": "length",
"title": "length(xs) → {number}",
"description": "#### length(xs) → {number}\n\nReturns the length of the list `xs`. Iterative process; time: `Theta(n)`, space: `Theta(1)`, where `n` is the length of `xs`.",
"meta": "func",
"parameters": [
"xs"
]
},
{
"label": "list",
"title": "list() → {list}",
"description": "#### list() → {list}\n\n\\*\\*primitive\\*\\*; given `n` values, returns a list of length `n`. The elements of the list are the given values in the given order; time: `Theta(n)Theta(n)`.",
"meta": "func",
"parameters": [],
"hasRestElement": true
},
{
"label": "list_ref",
"title": "list_ref(xs, n) → {value}",
"description": "#### list\\_ref(xs, n) → {value}\n\nReturns the element of list `xs` at position `n`, where the first element has index 0. Iterative process; time: `Theta(n)`, space: `Theta(1)`, where `n` is the length of `xs`.",
"meta": "func",
"parameters": [
"xs",
"n"
]
},
{
"label": "list_to_string",
"title": "list_to_string(xs) → {string}",
"description": "#### list\\_to\\_string(xs) → {string}\n\nReturns a string that represents list `xs` using the text-based box-and-pointer notation `[...]`. Iterative process; time: `Theta(n)` where `n` is the size of the list, space: `Theta(m)` where `m` is the length of the string. The process is iterative, but consumes space `O(m)` because of the result string.",
"meta": "func",
"parameters": [
"xs"
]
},
{
"label": "map",
"title": "map(f, xs) → {list}",
"description": "#### map(f, xs) → {list}\n\nReturns a list that results from list `xs` by element-wise application of unary function `f`. Iterative process; time: `Theta(n)` (apart from `f`), space: `Theta(n)` (apart from `f`), where `n` is the length of `xs`. `f` is applied element-by-element: `map(f, list(1, 2))` results in `list(f(1), f(2))`.",
"meta": "func",
"parameters": [
"x => ",
"xs"
]
},
{
"label": "math_abs",
"title": "math_abs(x) → {number}",
"description": "#### math\\_abs(x) → {number}\n\ncomputes the absolute value of x; the result has the same magnitude as `x` but has positive sign.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_acos",
"title": "math_acos(x) → {number}",
"description": "#### math\\_acos(x) → {number}\n\ncomputes the arc cosine of `x`. The result is expressed in radians and ranges from +0 to +π.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_acosh",
"title": "math_acosh(x) → {number}",
"description": "#### math\\_acosh(x) → {number}\n\ncomputes the inverse hyperbolic cosine of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_asin",
"title": "math_asin(x) → {number}",
"description": "#### math\\_asin(x) → {number}\n\ncomputes the arc sine of `x`. The result is expressed in radians and ranges from -π / 2 to +π / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_asinh",
"title": "math_asinh(x) → {number}",
"description": "#### math\\_asinh(x) → {number}\n\ncomputes the inverse hyperbolic sine of `x`. The result is expressed in radians and ranges from -π / 2 to +π / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_atan",
"title": "math_atan(x) → {number}",
"description": "#### math\\_atan(x) → {number}\n\ncomputes the arc tangent of `x`. The result is expressed in radians and ranges from -π / 2 to +π / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_atan2",
"title": "math_atan2(y, x) → {number}",
"description": "#### math\\_atan2(y, x) → {number}\n\ncomputes the arc tangent of the quotient `y` / `x` of the arguments `y` and `x`, where the signs of `y` and `x` are used to determine the quadrant of the result. Note that it is intentional and traditional for the two-argument arc tangent function that the argument named `y` be first and the argument named `x` be second. The result is expressed in radians and ranges from -π to +π.",
"meta": "func",
"parameters": [
"y",
"x"
]
},
{
"label": "math_atanh",
"title": "math_atanh(x) → {number}",
"description": "#### math\\_atanh(x) → {number}\n\ncomputes the inverse hyperbolic tangent of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_cbrt",
"title": "math_cbrt(x) → {number}",
"description": "#### math\\_cbrt(x) → {number}\n\ncomputes the cube root of `x`.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_ceil",
"title": "math_ceil(x) → {number}",
"description": "#### math\\_ceil(x) → {number}\n\ncomputes the smallest (closest to -∞) Number value that is not less than `x` and is an integer. If `x` is already an integer, the result is `x`. The value of math\\_ceil(x) is the same as the value of -math\\_floor(-x).",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_clz32",
"title": "math_clz32(n) → {number}",
"description": "#### math\\_clz32(n) → {number}\n\nWhen math\\_clz32 is called with one argument `x`, the following steps are taken: Let n be ToUint32(x). Let p be the number of leading zero bits in the 32-bit binary representation of n. Return p.\n\nNOTE: \nIf n is 0, p will be 32. If the most significant bit of the 32-bit binary encoding of n is 1, p will be 0.",
"meta": "func",
"parameters": [
"n"
]
},
{
"label": "math_cos",
"title": "math_cos(x) → {number}",
"description": "#### math\\_cos(x) → {number}\n\nComputes the cosine of `x`. The argument is expressed in radians.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_cosh",
"title": "math_cosh(x) → {number}",
"description": "#### math\\_cosh(x) → {number}\n\ncomputes the hyperbolic cosine of `x`.\n\nNOTE: The value of cosh(x) is the same as (exp(x) + exp(-x)) / 2.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_exp",
"title": "math_exp(x) → {number}",
"description": "#### math\\_exp(x) → {number}\n\ncomputes the exponential function of `x` (e raised to the power of `x`, where e is the base of the natural logarithms).",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_expm1",
"title": "math_expm1(x) → {number}",
"description": "#### math\\_expm1(x) → {number}\n\ncomputes subtracting 1 from the exponential function of `x` (e raised to the power of `x`, where e is the base of the natural logarithms). The result is computed in a way that is accurate even when the value of `x` is close to 0.",
"meta": "func",
"parameters": [
"x"
]
},
{
"label": "math_floor",