Skip to content

Commit

Permalink
fixes #802 (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz authored Jul 2, 2024
1 parent 452c6b7 commit 59a3725
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions xml/chapter3/section3/subsection1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ set_to_wow(z2);
<JAVASCRIPT>function</JAVASCRIPT>
</SPLITINLINE>
<SNIPPET EVAL="yes">
<NAME>count_pairs</NAME>
<INDEX><DECLARATION>count_pairs</DECLARATION><FRAGILE/></INDEX>
<SCHEME>
(define (count-pairs x)
Expand Down Expand Up @@ -1476,18 +1477,18 @@ function count_pairs(x) {
<SOLUTION>
<SNIPPET>
<NAME>exercise_3_16_solution</NAME>
<REQUIRES>count_pairs</REQUIRES>
<EXAMPLE>exercise_3_16_solution_example</EXAMPLE>
<SCHEME>
</SCHEME>
<JAVASCRIPT>
const cycle = make_cycle(three_list);

const three_list = list("a", "b", "c");

const one = pair("a", "b");
const three = pair(one, one);
const four = pair(three, "c");
const seven = pair(three, three);
const one = pair("d", "e");
const two = pair(one, one);
const four_list = pair(two, "f");
const seven_list = pair(two, two);
const cycle = list("g", "h", "i");
set_tail(tail(tail(cycle)), cycle);
</JAVASCRIPT>
</SNIPPET>

Expand All @@ -1496,8 +1497,8 @@ const seven = pair(three, three);
<JAVASCRIPT>
// return 3; return 4; return 7;
display(count_pairs(three_list));
display(count_pairs(four));
display(count_pairs(seven));
display(count_pairs(four_list));
display(count_pairs(seven_list));

// never return at all
display(count_pairs(cycle));
Expand Down

0 comments on commit 59a3725

Please sign in to comment.