Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 40 |
Nodes: | 6 (0 / 6) |
Uptime: | 11:16:07 |
Calls: | 291 |
Files: | 910 |
Messages: | 76,440 |
I have used NRECONC. When you are processing a list and the
interesting stuff is at the head of the list, you write a loop like
this:
(do ((tail list (cdr tail))
(processed '() (cons (do-something (car tail))
processed)))
((done? ...) (nreconc processed tail)))
The nreconc reverses the processed stuff (which is accumulated
backwards) and pastes it on to the remaining element of LIST.
Ah, finally a clue. Thanks for that!
Indeed, I could have used something like that before, but came up with a solution with LOOP that looks like this:
(loop for (car . cdr) on list
collect (do-something car) into processed
until done
finally (return (nconc processed cdr)))