UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

298 lines (297 loc) 23.7 kB
{ "Infinity": { "title": "Infinity:number", "description": "<div><h4>Infinity:number</h4><div class=\"description\">\n The name <code>Infinity</code> refers to the special number value <code>Infinity</code>.\nSee <a href=\"https://www.ecma-international.org/ecma-262/9.0/index.html#sec-value-properties-of-the-global-object-infinity\">ECMAScript Specification, Section 4.3.23</a>\n</div></div>", "meta": "const" }, "math_E": { "title": "math_E:number", "description": "<div><h4>math_E:number</h4><div class=\"description\">\n The Number value for e, Euler's number,\nwhich is approximately 2.718281828459045.\n</div></div>", "meta": "const" }, "math_LN2": { "title": "math_LN2:number", "description": "<div><h4>math_LN2:number</h4><div class=\"description\">\n The Number value for the natural logarithm of 2, \nwhich is approximately 0.6931471805599453.\n</div></div>", "meta": "const" }, "math_LN10": { "title": "math_LN10:number", "description": "<div><h4>math_LN10:number</h4><div class=\"description\">\n The Number value for the natural logarithm of 10, \nwhich is approximately 2.302585092994046.\n</div></div>", "meta": "const" }, "math_LOG2E": { "title": "math_LOG2E:number", "description": "<div><h4>math_LOG2E:number</h4><div class=\"description\">\n The Number value for the base-2 logarithm of eℝ, the base of the natural logarithms; \nthis value is approximately 1.4426950408889634.\n\n<p>NOTE:\nThe value of math_LOG2E is approximately the reciprocal of the value of math_LN2.\n</p></div></div>", "meta": "const" }, "math_LOG10E": { "title": "math_LOG10E:number", "description": "<div><h4>math_LOG10E:number</h4><div class=\"description\">\n The Number value for the base-10 logarithm of e, \nthe base of the natural logarithms; this value is approximately 0.4342944819032518.\n\n<p>NOTE:\nThe value of math_LOG10E is approximately the reciprocal of the value of math_LN10.\n</p></div></div>", "meta": "const" }, "math_PI": { "title": "math_PI:number", "description": "<div><h4>math_PI:number</h4><div class=\"description\">\n The Number value for π, the ratio of the circumference of a circle to its diameter, \nwhich is approximately 3.1415926535897932.\n</div></div>", "meta": "const" }, "math_SQRT1_2": { "title": "math_SQRT1_2:number", "description": "<div><h4>math_SQRT1_2:number</h4><div class=\"description\">\n The Number value for the square root of 0.5, which is approximately 0.7071067811865476.\n\n<p>NOTE:\nThe value of math_SQRT1_2 is approximately the reciprocal of the value of math_SQRT2.\n</p></div></div>", "meta": "const" }, "math_SQRT2": { "title": "math_SQRT2:number", "description": "<div><h4>math_SQRT2:number</h4><div class=\"description\">\n The Number value for the square root of 2, which is approximately 1.4142135623730951.\n</div></div>", "meta": "const" }, "NaN": { "title": "NaN:number", "description": "<div><h4>NaN:number</h4><div class=\"description\">\n The name <code>NaN</code> refers to the special number value <code>NaN</code> (\"not a number\"). Note that\n<code>NaN</code> is a number, as specified by <code>is_number</code>.\nSee <a href=\"https://www.ecma-international.org/ecma-262/9.0/index.html#sec-value-properties-of-the-global-object-nan\">ECMAScript Specification, Section 4.3.24</a>\n</div></div>", "meta": "const" }, "undefined": { "title": "undefined:undefined", "description": "<div><h4>undefined:undefined</h4><div class=\"description\">\n The name <code>undefined</code> refers to the special value <code>undefined</code>.\nSee also <a href=\"https://sourceacademy.org/sicpjs/4.1.1#h5\">textbook explanation in section 4.1.1</a>.\n</div></div>", "meta": "const" }, "arity": { "title": "arity(f) → {number}", "description": "<div><h4>arity(f) → {number}</h4><div class=\"description\">\n Returns the number of parameters the given function <code>f</code> expects,\nexcluding the rest parameter.\n</div></div>", "meta": "func" }, "char_at": { "title": "char_at(s, i) → {string}", "description": "<div><h4>char_at(s, i) → {string}</h4><div class=\"description\">\n Takes a string <code>s</code> as first argument and a nonnegative integer\n<code>i</code> as second argument. If <code>i</code> is less than the length\nof <code>s</code>, this function returns a one-character string that contains\nthe character of <code>s</code> at position <code>i</code>, counting from 0.\nIf <code>i</code> is larger than or equal to the length of\n<code>s</code>, this function returns <code>undefined</code>.\n</div></div>", "meta": "func" }, "display": { "title": "display(v, s) → {value}", "description": "<div><h4>display(v, s) → {value}</h4><div class=\"description\">\n Optional second argument. If present,\ndisplays the given string <code>s</code>, followed by a space character, followed by the\nvalue <code>v</code> in the console.\nIf second argument not present,\njust displays the value <code>v</code> in the console.\nThe notation used for the display of values\nis consistent with\n<a href=\"http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf\">JSON</a>,\nbut also displays <code>undefined</code>, <code>NaN</code>, <code>Infinity</code>, and function objects.\n</div></div>", "meta": "func" }, "error": { "title": "error(v, s)", "description": "<div><h4>error(v, s)</h4><div class=\"description\">\n Optional second argument.\nIf present,\ndisplays the given string <code>s</code>, followed by a space character, followed by the\nvalue <code>v</code> in the console with error flag.\nIf second argument not present,\njust displays the value <code>v</code> in the console with error flag.\nThe evaluation\nof any call of <code>error</code> aborts the running program immediately.\nThe notation used for the display of values\nis consistent with\n<a href=\"http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf\">JSON</a>,\nbut also displays <code>undefined</code>, <code>NaN</code>, <code>Infinity</code>, and function objects.\n</div></div>", "meta": "func" }, "get_time": { "title": "get_time() → {number}", "description": "<div><h4>get_time() → {number}</h4><div class=\"description\">\n Returns number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.\nSee also <a href=\"https://sourceacademy.org/sicpjs/1.2.6#ex-1.21\">textbook example</a>.\n</div></div>", "meta": "func" }, "is_boolean": { "title": "is_boolean(v) → {boolean}", "description": "<div><h4>is_boolean(v) → {boolean}</h4><div class=\"description\">\n checks whether a given value is a boolean\n</div></div>", "meta": "func" }, "is_function": { "title": "is_function(v) → {boolean}", "description": "<div><h4>is_function(v) → {boolean}</h4><div class=\"description\">\n checks whether a given value is a function\n</div></div>", "meta": "func" }, "is_number": { "title": "is_number(v) → {boolean}", "description": "<div><h4>is_number(v) → {boolean}</h4><div class=\"description\">\n checks whether a given value is a number.\nSee also <a href=\"https://sourceacademy.org/sicpjs/2.3.2\">textbook example</a>.\n</div></div>", "meta": "func" }, "is_string": { "title": "is_string(v) → {boolean}", "description": "<div><h4>is_string(v) → {boolean}</h4><div class=\"description\">\n checks whether a given value is a string.\nSee also <a href=\"https://sourceacademy.org/sicpjs/2.3.2\">textbook example</a>.\n</div></div>", "meta": "func" }, "is_undefined": { "title": "is_undefined(v) → {boolean}", "description": "<div><h4>is_undefined(v) → {boolean}</h4><div class=\"description\">\n checks whether a given value is the special value <code>undefined</code>\n</div></div>", "meta": "func" }, "math_abs": { "title": "math_abs(x) → {number}", "description": "<div><h4>math_abs(x) → {number}</h4><div class=\"description\">\n computes the absolute value of x; the result has the same magnitude as <code>x</code> but has positive sign.\n</div></div>", "meta": "func" }, "math_acos": { "title": "math_acos(x) → {number}", "description": "<div><h4>math_acos(x) → {number}</h4><div class=\"description\">\n computes the arc cosine of <code>x</code>. \nThe result is expressed in radians and ranges from +0 to +π.\n</div></div>", "meta": "func" }, "math_acosh": { "title": "math_acosh(x) → {number}", "description": "<div><h4>math_acosh(x) → {number}</h4><div class=\"description\">\n computes the inverse hyperbolic cosine of <code>x</code>.\n</div></div>", "meta": "func" }, "math_asin": { "title": "math_asin(x) → {number}", "description": "<div><h4>math_asin(x) → {number}</h4><div class=\"description\">\n computes the arc sine of <code>x</code>. The result is expressed in radians and ranges from -π / 2 to +π / 2.\n</div></div>", "meta": "func" }, "math_asinh": { "title": "math_asinh(x) → {number}", "description": "<div><h4>math_asinh(x) → {number}</h4><div class=\"description\">\n computes the inverse hyperbolic \nsine of <code>x</code>. The result is expressed in radians and ranges from -π / 2 to +π / 2.\n</div></div>", "meta": "func" }, "math_atan": { "title": "math_atan(x) → {number}", "description": "<div><h4>math_atan(x) → {number}</h4><div class=\"description\">\n computes the arc tangent of <code>x</code>. The result is expressed in radians and ranges from -π / 2 to +π / 2.\n</div></div>", "meta": "func" }, "math_atan2": { "title": "math_atan2(y, x) → {number}", "description": "<div><h4>math_atan2(y, x) → {number}</h4><div class=\"description\">\n computes the arc tangent of the quotient <code>y</code> / <code>x</code> of the arguments <code>y</code> and <code>x</code>, where the signs of <code>y</code> and <code>x</code> 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 <code>y</code> be first and the argument named <code>x</code> be second. The result is expressed in radians and ranges from -π to +π.\n</div></div>", "meta": "func" }, "math_atanh": { "title": "math_atanh(x) → {number}", "description": "<div><h4>math_atanh(x) → {number}</h4><div class=\"description\">\n computes the inverse hyperbolic tangent of <code>x</code>.\n</div></div>", "meta": "func" }, "math_cbrt": { "title": "math_cbrt(x) → {number}", "description": "<div><h4>math_cbrt(x) → {number}</h4><div class=\"description\">\n computes the cube root of <code>x</code>.\n</div></div>", "meta": "func" }, "math_ceil": { "title": "math_ceil(x) → {number}", "description": "<div><h4>math_ceil(x) → {number}</h4><div class=\"description\">\n computes the smallest (closest to -∞) Number value that is not less than <code>x</code> and is an integer. If <code>x</code> is already an integer, the result is <code>x</code>.\nThe value of math_ceil(x) is the same as the value of -math_floor(-x).\n</div></div>", "meta": "func" }, "math_clz32": { "title": "math_clz32(n) → {number}", "description": "<div><h4>math_clz32(n) → {number}</h4><div class=\"description\">\n When math_clz32 is called with one argument <code>x</code>, the following steps are taken:\n\nLet n be ToUint32(x).\nLet p be the number of leading zero bits in the 32-bit binary representation of n.\nReturn p.\n\n<p>NOTE:\n<br>If n is 0, p will be 32. If the most significant bit of the 32-bit binary encoding of n is 1, \np will be 0.\n</p></div></div>", "meta": "func" }, "math_cos": { "title": "math_cos(x) → {number}", "description": "<div><h4>math_cos(x) → {number}</h4><div class=\"description\">\n Computes the cosine of <code>x</code>. \nThe argument is expressed in radians.\n</div></div>", "meta": "func" }, "math_cosh": { "title": "math_cosh(x) → {number}", "description": "<div><h4>math_cosh(x) → {number}</h4><div class=\"description\">\n computes the hyperbolic cosine of <code>x</code>.\n<p>NOTE:\nThe value of cosh(x) is the same as (exp(x) + exp(-x)) / 2.\n</p></div></div>", "meta": "func" }, "math_exp": { "title": "math_exp(x) → {number}", "description": "<div><h4>math_exp(x) → {number}</h4><div class=\"description\">\n computes the exponential function of <code>x</code> \n(e raised to the power of <code>x</code>, where e is the base of the natural logarithms).\n</div></div>", "meta": "func" }, "math_expm1": { "title": "math_expm1(x) → {number}", "description": "<div><h4>math_expm1(x) → {number}</h4><div class=\"description\">\n computes subtracting 1 from the \nexponential function of <code>x</code> (e raised to the power of <code>x</code>, where e is the base of \nthe natural logarithms). The result is computed in a way that is accurate even \nwhen the value of <code>x</code> is close to 0.\n</div></div>", "meta": "func" }, "math_floor": { "title": "math_floor(x) → {number}", "description": "<div><h4>math_floor(x) → {number}</h4><div class=\"description\">\n computes the greatest (closest to +∞) Number value that is not greater than <code>x</code> \nand is an integer. \n<br>If <code>x</code> is already an integer, the result is <code>x</code>.\n\n<p>NOTE:\nThe value of math_floor(x) is the same as the value of -math_ceil(-x).\n</p></div></div>", "meta": "func" }, "math_fround": { "title": "math_fround(x) → {number}", "description": "<div><h4>math_fround(x) → {number}</h4><div class=\"description\">\n When math_fround is called with argument <code>x</code>, the following steps are taken:\n\n<ol><li>If <code>x</code> is NaN, return NaN.</li>\n<li>If <code>x</code> is one of +0, -0, +∞, -∞, return <code>x</code>.</li>\n<li>Let x32 be the result of converting <code>x</code> to a value in IEEE 754-2008 binary32 format using roundTiesToEven mode.</li>\n<li>Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.</li>\n<li>Return the ECMAScript Number value corresponding to x64.</li></ol>\n</div></div>", "meta": "func" }, "math_hypot": { "title": "math_hypot() → {number}", "description": "<div><h4>math_hypot() → {number}</h4><div class=\"description\">\n computes the square root\nof the sum of squares of its arguments.\n\n<br>If no arguments are passed, the result is +0.\n</div></div>", "meta": "func" }, "math_imul": { "title": "math_imul(x, x) → {number}", "description": "<div><h4>math_imul(x, x) → {number}</h4><div class=\"description\">\n When math_imul is called with arguments <code>x</code> and <code>y</code>,\nthe following steps are taken:\n<ol>\n<li>Let a be ToUint32(x).</li>\n<li>Let b be ToUint32(y).</li>\n<li>Let product be (a × b) modulo 2<sup>32</sup>.</li>\n<li>If product ≥ 2<sup>31</sup>, return product - 2<sup>32</sup>; otherwise return product.</li></ol>\n</div></div>", "meta": "func" }, "math_log": { "title": "math_log(x) → {number}", "description": "<div><h4>math_log(x) → {number}</h4><div class=\"description\">\n Computes the natural logarithm of <code>x</code>.\n</div></div>", "meta": "func" }, "math_log1p": { "title": "math_log1p(x) → {number}", "description": "<div><h4>math_log1p(x) → {number}</h4><div class=\"description\">\n computes the natural logarithm of 1 + <code>x</code>. The result is computed in a way that is accurate even when the value of <code>x</code> is close to zero.\n</div></div>", "meta": "func" }, "math_log2": { "title": "math_log2(x) → {number}", "description": "<div><h4>math_log2(x) → {number}</h4><div class=\"description\">\n computes the base 2 logarithm of <code>x</code>.\n</div></div>", "meta": "func" }, "math_log10": { "title": "math_log10(x) → {number}", "description": "<div><h4>math_log10(x) → {number}</h4><div class=\"description\">\n computes the base 10 logarithm of <code>x</code>.\n</div></div>", "meta": "func" }, "math_max": { "title": "math_max() → {number}", "description": "<div><h4>math_max() → {number}</h4><div class=\"description\">\n Given zero or more numbers, returns the largest of them.\n\n<br>If no arguments are given, the result is -∞.\n<br>If any value is NaN, the result is NaN.\nThe comparison of values to determine the largest value is done using the \nAbstract Relational Comparison algorithm except that +0 is considered to be larger than -0.\n</div></div>", "meta": "func" }, "math_min": { "title": "math_min() → {number}", "description": "<div><h4>math_min() → {number}</h4><div class=\"description\">\n Given zero or more arguments, returns the smallest of them.\n\n<br>If no arguments are given, the result is +∞.\n<br>If any value is NaN, the result is NaN.\nThe comparison of values to determine the smallest value is done using the \nAbstract Relational Comparison algorithm except that +0 is considered to be larger than -0.\n</div></div>", "meta": "func" }, "math_pow": { "title": "math_pow(base, exponent) → {number}", "description": "<div><h4>math_pow(base, exponent) → {number}</h4><div class=\"description\">\n Computes the result of raising base to \nthe power of exponent.\n</div></div>", "meta": "func" }, "math_random": { "title": "math_random() → {number}", "description": "<div><h4>math_random() → {number}</h4><div class=\"description\">\n Returns a number value with positive sign, greater than or equal to 0 but less than 1, \nchosen randomly or pseudo randomly with approximately uniform distribution over that \nrange, using an implementation-dependent algorithm or strategy. This function takes no arguments.\n\nEach math_random function created for distinct realms must produce a distinct sequence \nof values from successive calls.\n</div></div>", "meta": "func" }, "math_round": { "title": "math_round(x) → {number}", "description": "<div><h4>math_round(x) → {number}</h4><div class=\"description\">\n Returns the number value that is closest to <code>x</code> and is an integer. \n<br>If two integers are equally close to <code>x</code>, then the result is the Number value \nthat is closer to +∞. If <code>x</code> is already an integer, the result is <code>x</code>.\n\nNOTE 1:\nmath_round(3.5) returns 4, but math_round(-3.5) returns -3.\n</div></div>", "meta": "func" }, "math_sign": { "title": "math_sign(x) → {number}", "description": "<div><h4>math_sign(x) → {number}</h4><div class=\"description\">\n Computes the sign of <code>x</code>, indicating whether <code>x</code> is positive, negative, or zero.\n</div></div>", "meta": "func" }, "math_sin": { "title": "math_sin(x) → {number}", "description": "<div><h4>math_sin(x) → {number}</h4><div class=\"description\">\n Computes the sine of <code>x</code>. \nThe argument is expressed in radians.\n</div></div>", "meta": "func" }, "math_sinh": { "title": "math_sinh(x) → {number}", "description": "<div><h4>math_sinh(x) → {number}</h4><div class=\"description\">\n Computes the hyperbolic sine of <code>x</code>.\n<p>NOTE:\nThe value of sinh(x) is the same as (exp(x) - exp(-x)) / 2.\n</p></div></div>", "meta": "func" }, "math_sqrt": { "title": "math_sqrt(x) → {number}", "description": "<div><h4>math_sqrt(x) → {number}</h4><div class=\"description\">\n Computes the square root of <code>x</code>.\n</div></div>", "meta": "func" }, "math_tan": { "title": "math_tan(x) → {number}", "description": "<div><h4>math_tan(x) → {number}</h4><div class=\"description\">\n Computes the tangent of <code>x</code>. The argument is expressed in radians.\n</div></div>", "meta": "func" }, "math_tanh": { "title": "math_tanh(x) → {number}", "description": "<div><h4>math_tanh(x) → {number}</h4><div class=\"description\">\n Computes the hyperbolic tangent of <code>x</code>.\n\n<p>NOTE:\nThe value of <code>math_tanh(x)</code> is the same as\n<code>(exp(x) - exp(-x))/(exp(x) + exp(-x))</code>.\n</p></div></div>", "meta": "func" }, "math_trunc": { "title": "math_trunc(x) → {number}", "description": "<div><h4>math_trunc(x) → {number}</h4><div class=\"description\">\n Computes the integral part of the number <code>x</code>,\nremoving any fractional digits.\n</div></div>", "meta": "func" }, "parse_int": { "title": "parse_int(s, i) → {number}", "description": "<div><h4>parse_int(s, i) → {number}</h4><div class=\"description\">\n Interprets a given string <code>s</code> as an integer,\nusing the positive integer <code>i</code> as radix,\nand returns the respective value.\n<br>Examples: <code>parse_int(\"909\", 10)</code> returns the number\n<code>909</code>, and <code>parse_int(\"-1111\", 2)</code> returns the number\n<code>-15</code>.<br>\nSee <a href=\"https://www.ecma-international.org/ecma-262/9.0/index.html#sec-parseint-string-radix\">ECMAScript Specification, Section 18.2.5</a> for details.\n</div></div>", "meta": "func" }, "prompt": { "title": "prompt(s) → {string}", "description": "<div><h4>prompt(s) → {string}</h4><div class=\"description\">\n Pops up a window that displays the string <code>s</code>, provides\nan input line for the user to enter a text, a <code>Cancel</code> button and an <code>OK</code> button.\nThe call of <code>prompt</code>\nsuspends execution of the program until one of the two buttons is pressed. If\nthe <code>OK</code> button is pressed, <code>prompt</code> returns the entered text as a string.\nIf the <code>Cancel</code> button is pressed, <code>prompt</code> returns a non-string value.\n</div></div>", "meta": "func" }, "stringify": { "title": "stringify(v) → {string}", "description": "<div><h4>stringify(v) → {string}</h4><div class=\"description\">\n returns a string that represents the value <code>v</code>, using a\nnotation that is is consistent with\n<a href=\"http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf\">JSON</a>,\nbut also displays <code>undefined</code>, <code>NaN</code>, <code>Infinity</code>, and function objects.\nSee also <a href=\"https://sourceacademy.org/sicpjs/3.3.5\">textbook example</a>.\n</div></div>", "meta": "func" } }