Skip to content

Commit 35cc975

Browse files
authored
Merge pull request #341 from DieuMerci225/chapter7listing
Chapter7listing
2 parents 18ce6ad + 29ac12b commit 35cc975

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

source/ch7_recursion.ptx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@ public class ArrayProcessor {
315315
</p>
316316

317317
<p>
318-
The following Python code demonstrates a situation where a function calls itself indefinitely without a base case, leading to a <c>RecursionError</c> due to overflowing the call stack.
318+
The following Python code in <xref ref="python-recursion-error" text="type-global"/>demonstrates a situation where a function calls itself indefinitely without a base case, leading to a <c>RecursionError</c> due to overflowing the call stack.
319319
</p>
320-
<program xml:id="python-recursion-error" interactive="activecode" language="python">
321-
<code>
320+
<listing xml:id="python-recursion-error">
321+
<program interactive="activecode" language="python">
322+
<code>
322323
def cause_recursion_error():
323324
"""
324325
This function calls itself without a base case, guaranteeing an error.
@@ -334,12 +335,14 @@ public class ArrayProcessor {
334335
cause_recursion_error()
335336
</code>
336337
</program>
338+
</listing>
337339

338340
<p>
339-
The following Java code demonstrates a similar situation, where a method calls itself indefinitely without a base case, leading to a <c>StackOverflowError</c>.
341+
The following Java code in <xref ref="java-stack-overflow" text="type-global"/> demonstrates a similar situation, where a method calls itself indefinitely without a base case, leading to a <c>StackOverflowError</c>.
340342
</p>
341-
<program xml:id="java-stack-overflow" interactive="activecode" language="java">
342-
<code>
343+
<listing xml:id="java-stack-overflow">
344+
<program interactive="activecode" language="java">
345+
<code>
343346
public class Crash {
344347
public static void causeStackOverflow() {
345348
// The line below will start the infinite recursion.
@@ -357,6 +360,7 @@ public class ArrayProcessor {
357360
}
358361
</code>
359362
</program>
363+
</listing>
360364
</section>
361365

362366
<section xml:id="recursion_summary">

0 commit comments

Comments
 (0)