Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add primitive functions for list support #5

Merged
merged 2 commits into from
Feb 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ unop ::= !
function is_self_evaluating(stmt) {
return is_number(stmt) ||
is_string(stmt) ||
is_boolean(stmt);
is_boolean(stmt) ||
is_null(stmt);
}

// all other statements and expressions are
Expand Down Expand Up @@ -116,22 +117,6 @@ function analyze_name(stmt) {
};
}

/* Lists */
function is_list(stmt) {
return is_tagged_list(stmt, "array_expression");
}

function list_exp_list(stmt) {
return head(tail(stmt));
}

function analyze_list(stmt) {
const list_element_funcs = map(analyze, list_exp_list(stmt));
return (env, succeed, fail) => {

};
}

/* CONSTANT DECLARATIONS */

// constant declarations are tagged with "constant_declaration"
Expand Down Expand Up @@ -802,6 +787,10 @@ const the_empty_environment = null;
const primitive_functions = list(
list("display", display ),
list("error", error ),
list("list", list ),
list("pair", pair ),
list("head", head ),
list("tail", tail ),
list("+", (x,y) => x + y ),
list("-", (x,y) => x - y ),
list("*", (x,y) => x * y ),
Expand Down