Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Section - [3-15] I'm using DO to do some iteration, but it doesn't terminate.

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Schools ]


Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Previous Document: [3-14] When producing formatted output in Lisp, where should you put the newlines (e.g., before or after the line, FRESH-LINE vs TERPRI,
Next Document: [3-16] My program works when interpreted but not when compiled!
See reader questions & answers on this topic! - Help others by sharing your knowledge

Your code probably looks something like
   (do ((sublist list (cdr list))
        ..)
       ((endp sublist)
        ..)
     ..)
or maybe
   (do ((index start (+ start 2))
        ..)
       ((= index end)
        ..)
     ..)

The problem is caused by the (cdr list) and the (+ start 2) in the
first line. You're using the original list and start index instead of
the working sublist or index. Change them to (cdr sublist) and 
(+ index 2) and your code should start working.

User Contributions:

Comment about this article, ask questions, or add new information about this topic: