From: Jeff Barnett
Subject: Question about loop
Date: 
Message-ID: <465e60fb$0$4729$4c368faf@roadrunner.com>
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)))

-- Jeff Barnett

From: Pascal Costanza
Subject: Re: Question about loop
Date: 
Message-ID: <5c78auF2uio6kU1@mid.individual.net>
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/
From: Jeff Barnett
Subject: Re: Question about loop
Date: 
Message-ID: <465f8564$0$16512$4c368faf@roadrunner.com>
Pascal Costanza wrote:
> 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
>
That of course would not be equivalent to what I wrote and asked about. 
There may be other pointers to list or some of its eventual cdrs. The 
basic question is can (extended) loop be used to write certain 
destructive primitives or must we revert to the "machine language" parts 
of Lisp? At the time the standards were being formed, this question was 
well discussed. When I looked to see what was written now days, the 
literature was mute on the topic.

-- Jeff Barnett
From: Alex Mizrahi
Subject: Re: Question about loop
Date: 
Message-ID: <465ef421$0$90276$14726298@news.sunsite.dk>
(message (Hello 'Jeff)
(you :wrote  :on '(Wed, 30 May 2007 22:45:37 -0700))
(

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

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

i suspect it won't work right, but it's very confusing and very inefficient 
anyway.

what's about one of this:

(delete-if #'p list)

(loop for x in lisp unless (p x) collect x)

(mapcan (lambda (x) (unless (p x) (list x))) list)

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"I am everything you want and I am everything you need")