Predeclared in MCE

Below you find all constants and functions used in the textbook Structure and Interpretation of Computer Programs, JavaScript Adaptation (SICP JS). These constants and functions are predeclared in the language Source ยง4, a JavaScript sublanguage implemented in the Source Academy.

Can I use these constants and functions without the Source Academy ?

Yes, these constants and functions are provided by the NPM package sicp. You can use this package to run the JavaScript programs of SICP JS in any JavaScript system that is based on Node.js. Follow the link for installation instructions.

Functions

apply_in_underlying_javascript(f, xs) → {whatever}

calls the function f with arguments given in list xs. For example:
function times(x, y) {
return x * y;
}
apply_in_underlying_javascript(times, list(2, 3)); // returns 6
Parameters:
Name Type Description
f function function to be applied
xs list arguments given in list
Returns:
whatever f returns
Type
whatever

parse(x) → {value}

returns the parse tree that results from parsing the string str as a Source program. The format of the parse tree is described in chapter 4 of the textbook in Structure and Interpretation of Computer Programs, JavaScript Adaptation (SICP).
Parameters:
Name Type Description
x string given program as a string
Returns:
parse tree
Type
value

tokenize(x) → {list}

returns the list of tokens that results from lexing the string str
Parameters:
Name Type Description
x string given program as a string
Returns:
list of tokens
Type
list