Subject: Re: [LISP Beginner] Recursion Problem From: Erik Naggum <firstname.lastname@example.org> Date: Sun, 11 Nov 2001 19:44:00 GMT Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * Ingo Rohlfs <firstname.lastname@example.org> | What I'm doing wrong? Basically, using recursion for this problem, which is only confusing yourself and wasting a lot of space. This is a shot with a _much_ more powerful technique, iteration, using loop, which is very good for this kind of problem. (Some would tell you that since it is possible to get lost in loop, you should not even try it. Ignore them and trust your own ability to recognize when you are about to get lost. The same is true of recursion, when you get lost in it, it is unsuited for the task. Some people, especially those overexposed to Scheme, never seem to grasp this.) (defun get-elements (sequence) (loop for start = 0 then (1+ end) for end = (position #\Space sequence :start start) collect (subseq sequence start end) until (not end))) /// -- Norway is now run by a priest from the fundamentalist Christian People's Party, the fifth largest party representing one eighth of the electorate. -- Carrying a Swiss Army pocket knife in Oslo, Norway, is a criminal offense.