Skip to content

Commit eda9708

Browse files
committed
add xml:ids to all programs in ch5
1 parent 7287ff6 commit eda9708

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

source/ch5_loopsanditeration.ptx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
For example:
1616
</p>
1717

18-
<program interactive="activecode" language="python">
18+
<program xml:id="python-definite-loop" interactive="activecode" language="python">
1919
<code>
2020
for i in range(10):
2121
print(i)
@@ -26,7 +26,7 @@ for i in range(10):
2626
In Java, we would write this as:
2727
</p>
2828

29-
<program interactive="activecode" language="java">
29+
<program xml:id="pjava-definite-loop" interactive="activecode" language="java">
3030
<code>
3131
public class DefiniteLoopExample {
3232
public static void main(String[] args) {
@@ -65,7 +65,7 @@ public class DefiniteLoopExample {
6565
If you want to start at 100, stop at 0 and count backward by 5, the Python loop would be written as:
6666
</p>
6767

68-
<program interactive="activecode" language="python">
68+
<program xml:id="python-deinite-decrement" interactive="activecode" language="python">
6969
<code>
7070
for i in range(100, -1, -5):
7171
print(i)
@@ -76,7 +76,7 @@ for i in range(100, -1, -5):
7676
In Java, we would write this as:
7777
</p>
7878

79-
<program interactive="activecode" language="java">
79+
<program xml:id="java-definite-decrement" interactive="activecode" language="java">
8080
<code>
8181
public class DefiniteLoopBackward {
8282
public static void main(String[] args) {
@@ -97,7 +97,7 @@ public class DefiniteLoopBackward {
9797
In Python, we can iterate over a list as follows:
9898
</p>
9999

100-
<program interactive="activecode" language="python">
100+
<program xml:id="python-list-iteration" interactive="activecode" language="python">
101101
<code>
102102
l = [1, 1, 2, 3, 5, 8, 13, 21]
103103
for fib in l:
@@ -109,7 +109,7 @@ for fib in l:
109109
In Java we can iterate over an <c>ArrayList</c> of integers too. Note that this requires importing the <c>ArrayList</c> class.
110110
</p>
111111

112-
<program interactive="activecode" language="java">
112+
<program xml:id="java-list-iteration" interactive="activecode" language="java">
113113
<code>
114114
import java.util.ArrayList;
115115

@@ -134,10 +134,10 @@ public class ForEachArrayListExample {
134134

135135
<p>
136136
This example stretches the imagination a bit, and in fact points out one area where Java's primitive arrays are easier to use than an array list.
137-
In fact all primitive arrays can be used in a for each loop.
137+
In fact, all primitive arrays can be used in a <term>for each</term> loop.
138138
</p>
139139

140-
<program interactive="activecode" language="java">
140+
<program xml:id="java-for-each" interactive="activecode" language="java">
141141
<code>
142142
public class ForEachArrayExample {
143143
public static void main(String[] args) {
@@ -154,7 +154,7 @@ public class ForEachArrayExample {
154154
To iterate over the characters in a string in Java do the following:
155155
</p>
156156

157-
<program interactive="activecode" language="java">
157+
<program xml:id="java-string-iteration" interactive="activecode" language="java">
158158
<code>
159159
public class StringIterationExample {
160160
public static void main(String[] args) {
@@ -176,7 +176,7 @@ public class StringIterationExample {
176176
Both Python and Java support the <c>while</c> loop, which continues to execute as long as a condition is true.
177177
Here is a simple example in Python that counts down from 5:
178178
</p>
179-
<program interactive="activecode" language="python">
179+
<program xml:id="python-countdown" interactive="activecode" language="python">
180180
<code>
181181
i = 5
182182
while i &gt; 0:
@@ -186,9 +186,9 @@ while i &gt; 0:
186186
</program>
187187

188188
<p>
189-
In Java we add parenthesis and curly braces. Here is the same countdown loop in Java:
189+
In Java, we add parentheses and curly braces. Here is the same countdown loop in Java:
190190
</p>
191-
<program interactive="activecode" language="java">
191+
<program xml:id="java-countdown" interactive="activecode" language="java">
192192
<code>
193193
public class WhileLoopExample {
194194
public static void main(String[] args) {
@@ -210,7 +210,7 @@ public class WhileLoopExample {
210210
For example, the following loop will execute once even though the condition is initially false.
211211
</p>
212212

213-
<program interactive="activecode" language="java">
213+
<program xml:id="java-do-while" interactive="activecode" language="java">
214214
<code>
215215
public class DoWhileExample {
216216
public static void main(String[] args) {

0 commit comments

Comments
 (0)