Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xml/chapter1/section2/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ function pascal_triangle(row, index) {
<REQUIRES>pascal_triangle</REQUIRES>
<EXPECTED>4</EXPECTED>
<JAVASCRIPT>
pascal_triangle(5,4);
pascal_triangle(5, 4);
</JAVASCRIPT>
<SCHEME>
</SCHEME>
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter1/section2/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ fast_expt(2, 3);
(+ a (* a (- b 1)))))
</SCHEME>
<JAVASCRIPT>
function times(a,b) {
function times(a, b) {
return b === 0
? 0
: a + times(a, b - 1);
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter2/section1/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function make_point(x, y) {
return pair(x, y);
}
function make_segment(start_point, end_point) {
return pair(start_point,end_point);
return pair(start_point, end_point);
}
function start_segment(x) {
return head(x);
Expand Down
4 changes: 2 additions & 2 deletions xml/chapter2/section1/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<SPLITINLINE>
<SCHEME><SCHEMEINLINE>(make-rat n d)</SCHEMEINLINE>,</SCHEME>
<JAVASCRIPT>
<JAVASCRIPTINLINE>make_rat(n,d)</JAVASCRIPTINLINE>,
<JAVASCRIPTINLINE>make_rat(n, d)</JAVASCRIPTINLINE>,
</JAVASCRIPT>
</SPLITINLINE>
then
Expand Down Expand Up @@ -546,7 +546,7 @@ function head(z) {
<EXAMPLE>cons_1_2_run_2</EXAMPLE>
<JAVASCRIPT>
function tail(z) {
return z((p,q) => q);
return z((p, q) => q);
}
</JAVASCRIPT>
<SCHEME>
Expand Down
8 changes: 4 additions & 4 deletions xml/chapter2/section1/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ function par2(r1, r2) {
<SNIPPET HIDE="yes">
<NAME>par_example</NAME>
<JAVASCRIPT>
display(print_interval(par1(pair(4,6), pair(7,8))));
display(print_interval(par1(pair(4, 6), pair(7, 8))));

display(print_interval(par2(pair(4,6), pair(7,8))));
display(print_interval(par2(pair(4, 6), pair(7, 8))));
</JAVASCRIPT>
<JAVASCRIPT_TEST>
print_interval(par1(pair(4,6), pair(7,8)))
print_interval(par1(pair(4, 6), pair(7, 8)))
+
print_interval(par2(pair(4,6), pair(7,8)));
print_interval(par2(pair(4, 6), pair(7, 8)));
</JAVASCRIPT_TEST>
</SNIPPET>
Lem complains that Alyssa<APOS/>s program gives different answers for
Expand Down
12 changes: 6 additions & 6 deletions xml/chapter2/section3/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ function union_set(set1, set2) {
(else (element-of-set? x (cdr set)))))
</SCHEME>
<JAVASCRIPT>
function is_element_of_set(x,set) {
function is_element_of_set(x, set) {
return is_null(set)
? false
: x === head(set)
Expand Down Expand Up @@ -925,7 +925,7 @@ function left_branch(tree) { return head(tail(tree)); }
function right_branch(tree) { return head(tail(tail(tree))); }
<SHORT_SPACE/>
function make_tree(entry, left, right) {
return list(entry,left,right);
return list(entry, left, right);
}
</JAVASCRIPT>
</SNIPPET>
Expand All @@ -950,7 +950,7 @@ entry(
make_tree(10,
null,
make_tree(30,
make_tree(20,null,null),
make_tree(20, null, null),
null)))));
</JAVASCRIPT>
</SNIPPET>
Expand Down Expand Up @@ -1052,7 +1052,7 @@ head(tail(head(tail(adjoin_set(10, adjoin_set(15, adjoin_set(20, null)))))));
(adjoin-set x (right-branch set))))))
</SCHEME>
<JAVASCRIPT>
function adjoin_set(x,set) {
function adjoin_set(x, set) {
return is_null(set)
? make_tree(x, null, null)
: x === entry(set)
Expand Down Expand Up @@ -1339,11 +1339,11 @@ function tree_to_list_2(tree) {
</SCHEME>
<JAVASCRIPT>
function list_to_tree(elements) {
return head(partial_tree(elements,length(elements)));
return head(partial_tree(elements, length(elements)));
}
function partial_tree(elts, n) {
if (n === 0) {
return pair(null,elts);
return pair(null, elts);
} else {
const left_size = math_floor((n - 1) / 2);
const left_result = partial_tree(elts, left_size);
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter2/section3/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ weight_leaf(my_leaf);
(+ (weight left) (weight right))))
</SCHEME>
<JAVASCRIPT>
function make_code_tree(left,right) {
function make_code_tree(left, right) {
return list("code_tree", left, right,
append(symbols(left), symbols(right)),
weight(left) + weight(right));
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter2/section4/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
(make-from-real-imag (real-part z) (imag-part z))
</SCHEME>
<JAVASCRIPT>
make_from_real_imag(real_part(z),imag_part(z));
make_from_real_imag(real_part(z), imag_part(z));
</JAVASCRIPT>
</SNIPPET>
and
Expand Down
14 changes: 7 additions & 7 deletions xml/chapter2/section5/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -736,17 +736,17 @@ apply_generic("magnitude", list(z));
// put("magnitude", list("complex"), magnitude);
// fun = magnitude;
apply(magnitude, map(contents, list(z)));
apply(magnitude, pair("rectangular", pair(3,4)));
magnitude(pair("rectangular"), pair(3,4));
apply_generic("magnitude", list(pair("rectangular"), pair(3,4)));
apply(magnitude, pair("rectangular", pair(3, 4)));
magnitude(pair("rectangular"), pair(3, 4));
apply_generic("magnitude", list(pair("rectangular"), pair(3, 4)));
// type_tags = map(type_tag, list(z)) evaluates to list("rectangular")
// fun = get("magnitude", list("rectangular")) which evaluates to
// z => math_sqrt(square(real_part(z)) + square(imag_part(z)))
// z => math_sqrt(square(head(z)) + square(tail(z)))
apply(fun, map(contents, list(pair("rectangular"), pair(3,4))))
apply(fun, pair(3,4))
(z => math_sqrt(square(head(z)) + square(tail(z))))(pair(3,4));
math_sqrt(square(head(pair(3,4))) + square(tail(pair(3,4))))
apply(fun, map(contents, list(pair("rectangular"), pair(3, 4))))
apply(fun, pair(3, 4))
(z => math_sqrt(square(head(z)) + square(tail(z))))(pair(3, 4));
math_sqrt(square(head(pair(3, 4))) + square(tail(pair(3, 4))))
...
math_sqrt(square(3) + square(4));
...
Expand Down
8 changes: 4 additions & 4 deletions xml/chapter3/section1/subsection3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -802,15 +802,15 @@ paul_acc("withdraw")(50);
</SCHEME>
<JAVASCRIPT>
function factorial(n) {
function iter(product,counter) {
function iter(product, counter) {
if (counter &gt; n) {
return product;
} else {
return iter(counter*product,
counter+1);
return iter(counter * product,
counter + 1);
}
}
return iter(1,1);
return iter(1, 1);
}
</JAVASCRIPT>
</SNIPPET>
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter3/section3/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ function append_mutator(x, y) {
<SNIPPET HIDE="yes">
<NAME>last_pair_example_2</NAME>
<JAVASCRIPT>
last_pair(list(1,2,3,4,5));
last_pair(list(1, 2, 3, 4, 5));
</JAVASCRIPT>
</SNIPPET>
<SNIPPET EVAL="yes">
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter3/section3/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function make_queue() { return pair(null, null); }
<SNIPPET HIDE="yes">
<NAME>front_queue_example</NAME>
<JAVASCRIPT>
const q = pair(pair(1,2), 3);
const q = pair(pair(1, 2), 3);
front_queue(q);
</JAVASCRIPT>
</SNIPPET>
Expand Down
4 changes: 2 additions & 2 deletions xml/chapter3/section5/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1372,10 +1372,10 @@ function stream_map_2(f, s1, s2) {
? null
: is_null(s1) || is_null(s2)
? error(null, "unexpected argument -- stream_map_2")
: pair(f(head(s1),head(s2)),
: pair(f(head(s1), head(s2)),
memo(() => stream_map_2(f, stream_tail(s1),
stream_tail(s2))));
}
}
</JAVASCRIPT>
</SNIPPET>
Similar to <JAVASCRIPTINLINE>stream_map_optimized</JAVASCRIPTINLINE>,
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter3/section5/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function stream_combine(f, s1, s2) {
? null
: is_null(s1) || is_null(s2)
? error(null, "unexpected argument -- stream_combine")
: pair(f(head(s1),head(s2)),
: pair(f(head(s1), head(s2)),
memo(() => stream_combine(f, stream_tail(s1),
stream_tail(s2))));
}
Expand Down
2 changes: 1 addition & 1 deletion xml/chapter4/section1/subsection2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ function literal_value(component) {
<NAME>is_literal_example</NAME>
<JAVASCRIPT>
const my_program = parse("true; 1;");
const my_true_statement = list_ref(list_ref(my_program, 1),0);
const my_true_statement = list_ref(list_ref(my_program, 1), 0);
is_literal(my_true_statement);
</JAVASCRIPT>
</SNIPPET>
Expand Down