Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 8 additions & 6 deletions xml/chapter2/section1/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,14 @@
</SCHEME>
<JAVASCRIPT>
function pair(x, y) {
return m =>
m === 0
? x
: m === 1
? y
: error(m, "Argument not 0 or 1 in pair");
function dispatch(m) {
return m === 0
? x
: m === 1
? y
: error(m, "Argument not 0 or 1 in pair:");
}
return dispatch;
}
function head(z) {
return z(0);
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter2/section4/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ function make_from_real_imag(x, y) {
: op === "angle"
? math_atan(y, x)
: error(op,
"Unknown op in make_from_real_imag");
"Unknown op in make_from_real_imag:");
}
return dispatch;
}
Expand Down
12 changes: 5 additions & 7 deletions xml/chapter3/section1/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -892,13 +892,11 @@ function make_account(balance) {
return balance;
}
function dispatch(m) {
if (m === "withdraw") {
return withdraw;
} else if (m === "deposit") {
return deposit;
} else {
return "Unknown request in make_account";
}
return m === "withdraw"
? withdraw
: m === "deposit"
? deposit
: error(m, "Unknown request in make_account");
}
return dispatch;
}
Expand Down
14 changes: 8 additions & 6 deletions xml/chapter3/section3/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1551,12 +1551,14 @@ function count_pairs(x) {
</SCHEME>
<JAVASCRIPT>
function pair(x, y) {
return m =>
m === "head"
? x
: m === "tail"
? y
: error(m, "Argument not 0 or 1 in pair");
function dispatch(m) {
return m === "head"
? x
: m === "tail"
? y
: error(m, "Undefined operation in pair:");
}
return dispatch;
}
function head(z) {
return z("head");
Expand Down
6 changes: 3 additions & 3 deletions xml/chapter3/section3/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,10 @@ delete_queue(q1);
</SCHEME>
<JAVASCRIPT>
function make_queue() {
function front_ptr(...) ...
function rear_ptr(...) ...
function front_ptr(...) {...}
function rear_ptr(...) {...}
//definitions of internal functions
function dispatch(m) ...
function dispatch(m) {...}
return dispatch;
}
</JAVASCRIPT>
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter3/section3/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function make_table() {
? lookup
: m === "insert"
? insert
: "undefined operation -- table";
: error(m, "Unknown operation in table:";
}
return dispatch;
}
Expand Down
39 changes: 24 additions & 15 deletions xml/chapter3/section4/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,17 @@ function make_account(balance) {
return balance;
}
const protect = make_serializer();
return m => m === "withdraw"
? protect(withdraw)
: m === "deposit"
? protect(deposit)
: m === "balance"
function dispatch(m) {
return m === "withdraw"
? protect(withdraw)
: m === "deposit"
? protect(deposit)
: m === "balance"
? balance
: error(m,
"Unknown request in make_account:");
}
return dispatch;
}
</JAVASCRIPT>
</SNIPPET>
Expand Down Expand Up @@ -625,14 +628,17 @@ function make_account(balance) {
return balance;
}
const protect = make_serializer();
return m => m === "withdraw"
? protect(withdraw)
: m === "deposit"
? protect(deposit)
: m === "balance"
function dispatch(m) {
return m === "withdraw"
? protect(withdraw)
: m === "deposit"
? protect(deposit)
: m === "balance"
? protect(_ => balance)(undefined) // serialized
: error(m,
"Unknown request in make_account:");
}
return dispatch;
}
</JAVASCRIPT>
</SNIPPET>
Expand Down Expand Up @@ -718,14 +724,17 @@ function make_account(balance) {
const protect = make_serializer();
const protect_withdraw = protect(withdraw);
const protect_deposit = protect(deposit);
return m => m === "withdraw"
? protect_withdraw
: m === "deposit"
? protect_deposit
: m === "balance"
function dispatch(m) {
return m === "withdraw"
? protect_withdraw
: m === "deposit"
? protect_deposit
: m === "balance"
? balance
: error(m,
"Unknown request in make_account:");
}
return dispatch;
}
</JAVASCRIPT>
</SNIPPET>
Expand Down