Re: Question about loop



Jeff Barnett wrote:
Does the Common Lisp spec say anything about whether the following is well defined given that the elements of "list" are unique:

(loop for x in list
when (p x)
do (setq list (delete x list)))

See http://www.lispworks.com/documentation/HyperSpec/Body/03_f.htm

But I wouldn't worry too much and just switch to a non-destructive version:

(loop for x in list
unless (p x) collect x into new-list
finally (setq list new-list))


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: Question about loop
    ... Jeff Barnett wrote: ... (loop for x in list ... There may be other pointers to list or some of its eventual cdrs. ... So if you require destructive changes to the list structure, you have to do it yourself anyway. ...
    (comp.lang.lisp)
  • Re: Why it does not work?
    ... Kenneth Tilton wrote: ... then I write (loop for i from 0 to 10 ... Closer to MOP & ContextL: http://common-lisp.net/project/closer/ ...
    (comp.lang.lisp)
  • Re: Fat pig lets her pittbull loose on a little animal control officer
    ... It looks like a little mop handle with a loop of twine on it. ... go get that huge pitbull with a mop. ...
    (alt.fan.howard-stern)
  • Re: I like(d) loop, but ..
    ... (loop for (name. ... (format t "~s~%" (funcall f))) ... Closer to MOP & ContextL: http://common-lisp.net/project/closer/ ...
    (comp.lang.lisp)