Skip to content

Commit e622dcd

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/xpath-0.0.34
2 parents b46883e + 7b7e2a5 commit e622dcd

File tree

5 files changed

+785
-744
lines changed

5 files changed

+785
-744
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
},
2626
"homepage": "https://sourceacademy.org/sicpjs",
2727
"devDependencies": {
28-
"@babel/node": "^7.22.19",
29-
"@babel/core": "^7.23.5",
30-
"@babel/preset-env": "^7.23.5",
28+
"@babel/node": "^7.24.6",
29+
"@babel/core": "^7.24.6",
30+
"@babel/preset-env": "^7.24.6",
3131
"fs-extra": "^11.2.0",
3232
"http-server": "^14.1.1",
3333
"husky": "^8.0.3",
34-
"js-slang": "^1.0.37",
34+
"js-slang": "^1.0.57",
3535
"lz-string": "^1.5.0",
3636
"prettier": "^2.8.8",
3737
"xmldom": "^0.6.0",

test_node_env/package-lock.json

+12-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xml/chapter2/section1/subsection4.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function the_trouble_maker(xl, xu, yl, yu) {
411411
const p2 = xl * yu;
412412
const p3 = xu * yl;
413413
const p4 = xu * yu;
414-
make_interval(math_min(p1, p2, p3, p4),
414+
return make_interval(math_min(p1, p2, p3, p4),
415415
math_max(p1, p2, p3, p4));
416416
}
417417
function mul_interval(x, y) {

xml/chapter2/section3/subsection2.xml

+22-11
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ list("x", "+", list(3, "*", list("x", "+", list("y", "+", 2))))
13401340
example:
13411341
<SNIPPET EVAL="no">
13421342
<JAVASCRIPT>
1343-
list("x", "+", "3", "*", list("x", "+", "y", "+", 2))
1343+
list("x", "+", 3, "*", list("x", "+", "y", "+", 2))
13441344
</JAVASCRIPT>
13451345
</SNIPPET>
13461346
</JAVASCRIPT>
@@ -1436,15 +1436,27 @@ deriv(list("x", "*", 4), "x");
14361436
<EXAMPLE>example_2.61_2</EXAMPLE>
14371437
<JAVASCRIPT>
14381438
function items_before_first(op, s) {
1439-
return head(s) === op
1439+
return is_string(head(s)) &amp;&amp; head(s) === op
14401440
? null
14411441
: pair(head(s),
14421442
items_before_first(op, tail(s)));
14431443
}
14441444
function items_after_first(op, s) {
1445-
return head(s) === op
1445+
return is_string(head(s)) &amp;&amp; head(s) === op
14461446
? tail(s)
1447-
: items_after_first(op, tail(s);
1447+
: items_after_first(op, tail(s));
1448+
}
1449+
function simplify_unary_list(s) {
1450+
return is_pair(s) &amp;&amp; is_null(tail(s))
1451+
? head(s)
1452+
: s;
1453+
}
1454+
function contains_plus(s) {
1455+
return is_null(s)
1456+
? false
1457+
: is_string(head(s)) &amp;&amp; head(s) === "+"
1458+
? true
1459+
: contains_plus(tail(s));
14481460
}
14491461
function make_sum(a1, a2) {
14501462
return number_equal(a1, 0)
@@ -1458,14 +1470,13 @@ function make_sum(a1, a2) {
14581470
// a sequence of terms and operators is a sum
14591471
// if and only if at least one + operator occurs
14601472
function is_sum(x) {
1461-
return is_pair(x) &amp;&amp;
1462-
! (is_null(member("+", x));
1473+
return is_pair(x) &amp;&amp; contains_plus(x);
14631474
}
14641475
function addend(s) {
1465-
return items_before_first("+", s);
1476+
return simplify_unary_list(items_before_first("+", s));
14661477
}
14671478
function augend(s) {
1468-
return items_after_first("+", s);
1479+
return simplify_unary_list(items_after_first("+", s));
14691480
}
14701481
function make_product(m1, m2) {
14711482
return number_equal(m1, 0) || number_equal(m2, 0)
@@ -1481,13 +1492,13 @@ function make_product(m1, m2) {
14811492
// a sequence of terms and operators is a product
14821493
// if and only if no + operator occurs
14831494
function is_product(x) {
1484-
return is_pair(x) &amp;&amp; is_null(member("+", x);
1495+
return is_pair(x) &amp;&amp; ! contains_plus(x);
14851496
}
14861497
function multiplier(s) {
1487-
return items_before_first("*", s);
1498+
return simplify_unary_list(items_before_first("*", s));
14881499
}
14891500
function multiplicand(s) {
1490-
return items_after_first("*", s);
1501+
return simplify_unary_list(items_after_first("*", s));
14911502
}
14921503
function deriv(exp, variable) {
14931504
return is_number(exp)

0 commit comments

Comments
 (0)