Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/xpath-0.0.34
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz authored Jun 30, 2024
2 parents b46883e + 7b7e2a5 commit e622dcd
Show file tree
Hide file tree
Showing 5 changed files with 785 additions and 744 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
},
"homepage": "https://sourceacademy.org/sicpjs",
"devDependencies": {
"@babel/node": "^7.22.19",
"@babel/core": "^7.23.5",
"@babel/preset-env": "^7.23.5",
"@babel/node": "^7.24.6",
"@babel/core": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"fs-extra": "^11.2.0",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"js-slang": "^1.0.37",
"js-slang": "^1.0.57",
"lz-string": "^1.5.0",
"prettier": "^2.8.8",
"xmldom": "^0.6.0",
Expand Down
26 changes: 12 additions & 14 deletions test_node_env/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion xml/chapter2/section1/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function the_trouble_maker(xl, xu, yl, yu) {
const p2 = xl * yu;
const p3 = xu * yl;
const p4 = xu * yu;
make_interval(math_min(p1, p2, p3, p4),
return make_interval(math_min(p1, p2, p3, p4),
math_max(p1, p2, p3, p4));
}
function mul_interval(x, y) {
Expand Down
33 changes: 22 additions & 11 deletions xml/chapter2/section3/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ list("x", "+", list(3, "*", list("x", "+", list("y", "+", 2))))
example:
<SNIPPET EVAL="no">
<JAVASCRIPT>
list("x", "+", "3", "*", list("x", "+", "y", "+", 2))
list("x", "+", 3, "*", list("x", "+", "y", "+", 2))
</JAVASCRIPT>
</SNIPPET>
</JAVASCRIPT>
Expand Down Expand Up @@ -1436,15 +1436,27 @@ deriv(list("x", "*", 4), "x");
<EXAMPLE>example_2.61_2</EXAMPLE>
<JAVASCRIPT>
function items_before_first(op, s) {
return head(s) === op
return is_string(head(s)) &amp;&amp; head(s) === op
? null
: pair(head(s),
items_before_first(op, tail(s)));
}
function items_after_first(op, s) {
return head(s) === op
return is_string(head(s)) &amp;&amp; head(s) === op
? tail(s)
: items_after_first(op, tail(s);
: items_after_first(op, tail(s));
}
function simplify_unary_list(s) {
return is_pair(s) &amp;&amp; is_null(tail(s))
? head(s)
: s;
}
function contains_plus(s) {
return is_null(s)
? false
: is_string(head(s)) &amp;&amp; head(s) === "+"
? true
: contains_plus(tail(s));
}
function make_sum(a1, a2) {
return number_equal(a1, 0)
Expand All @@ -1458,14 +1470,13 @@ function make_sum(a1, a2) {
// a sequence of terms and operators is a sum
// if and only if at least one + operator occurs
function is_sum(x) {
return is_pair(x) &amp;&amp;
! (is_null(member("+", x));
return is_pair(x) &amp;&amp; contains_plus(x);
}
function addend(s) {
return items_before_first("+", s);
return simplify_unary_list(items_before_first("+", s));
}
function augend(s) {
return items_after_first("+", s);
return simplify_unary_list(items_after_first("+", s));
}
function make_product(m1, m2) {
return number_equal(m1, 0) || number_equal(m2, 0)
Expand All @@ -1481,13 +1492,13 @@ function make_product(m1, m2) {
// a sequence of terms and operators is a product
// if and only if no + operator occurs
function is_product(x) {
return is_pair(x) &amp;&amp; is_null(member("+", x);
return is_pair(x) &amp;&amp; ! contains_plus(x);
}
function multiplier(s) {
return items_before_first("*", s);
return simplify_unary_list(items_before_first("*", s));
}
function multiplicand(s) {
return items_after_first("*", s);
return simplify_unary_list(items_after_first("*", s));
}
function deriv(exp, variable) {
return is_number(exp)
Expand Down
Loading

0 comments on commit e622dcd

Please sign in to comment.