[Gd-chatter] r10894 - trunk/www/books/dpg

tim at gwydiondylan.org tim at gwydiondylan.org
Mon Sep 4 05:18:59 CEST 2006


Author: tim
Date: Mon Sep  4 05:18:57 2006
New Revision: 10894

Modified:
   trunk/www/books/dpg/db_148.html
Log:
job: website

fixed typo


Modified: trunk/www/books/dpg/db_148.html
==============================================================================
--- trunk/www/books/dpg/db_148.html	(original)
+++ trunk/www/books/dpg/db_148.html	Mon Sep  4 05:18:57 2006
@@ -34,7 +34,7 @@
   new-list;
 end method my-copy-sequence;
 </pre>
-<p>First, <code>my-copy-sequence</code> makes a new list that is the same length as the old one. Next, the <code>for</code> iterator is used to bind the variables <code>old</code> and <code>new</code> to <code>old-list</code> and <code>new-list</code>, respectively. Then, the <code>for</code> iterator executes the <code>until:</code> expression to determine whether it is time to terminate the loop. If the <code>until:</code> expression returns true, then the <code>for</code> loop terminates, and the newly created list is returned from <code>my-copy-sequence</code>. Otherwise, the body of the <code>for</code> loop is executed &mdash; the body stores the head of the first pair in <code>old</code> into the head of the first pair in <code>new</code>. The result of that action is that the first element of <code>new</code> is indentical to the first element of <code>old</code>. For this iteration, that action causes the first element of <code>new-list</code> to be identical to the first element of <code>old-list</code>. In subsequent iterations, the body will access elements 1 closer to the end of the list. It will do so because, after the body is executed, the <code>for</code> iterator loops back to the iterator clauses, where the <code>then</code> clauses bind <code>old</code> to all but the first pair of <code>old</code>, and bind <code>new</code> to all but the first pair of <code>new</code>. The termination check occurs again, with the same consequences, depending on the value of the <code>until:</code> expression. Iteration then continues just like the second time through the loop until the end of <code>old</code> is reached.</p>
+<p>First, <code>my-copy-sequence</code> makes a new list that is the same length as the old one. Next, the <code>for</code> iterator is used to bind the variables <code>old</code> and <code>new</code> to <code>old-list</code> and <code>new-list</code>, respectively. Then, the <code>for</code> iterator executes the <code>until:</code> expression to determine whether it is time to terminate the loop. If the <code>until:</code> expression returns true, then the <code>for</code> loop terminates, and the newly created list is returned from <code>my-copy-sequence</code>. Otherwise, the body of the <code>for</code> loop is executed &mdash; the body stores the head of the first pair in <code>old</code> into the head of the first pair in <code>new</code>. The result of that action is that the first element of <code>new</code> is identical to the first element of <code>old</code>. For this iteration, that action causes the first element of <code>new-list</code> to be identical to the first element of <code>old-list</code>. In subsequent iterations, the body will access elements 1 closer to the end of the list. It will do so because, after the body is executed, the <code>for</code> iterator loops back to the iterator clauses, where the <code>then</code> clauses bind <code>old</code> to all but the first pair of <code>old</code>, and bind <code>new</code> to all but the first pair of <code>new</code>. The termination check occurs again, with the same consequences, depending on the value of the <code>until:</code> expression. Iteration then continues just like the second time through the loop until the end of <code>old</code> is reached.</p>
 <p>In this method, we never have to search for the current spot of the old list that we are copying, or to search for the end of the new list that we are building. The variables <code>old</code> and <code>new</code> track exactly which pairs in the iteration to access, and that tracking saves a considerable amount of time for large lists. When the iteration is finished, <code>my-copy-sequence</code> returns the new list.</p>
 
 </div>



More information about the chatter mailing list