How can I remove all the items of a list?
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
How can I remove all the items of a list?

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Cadence
Author Message
Guest






Posted: Tue Nov 16, 2004 11:50 am    Post subject: How can I remove all the items of a list? Reply with quote

Hello all,
By using the SKILL function remd, I can remove some items of a
list. But how can I remove all the items of a list? In other words, how
can I make a list be empty?
Thanks.

Back to top
Jim Newton
Guest





Posted: Tue Nov 16, 2004 12:10 pm    Post subject: Re: How can I remove all the items of a list? Reply with quote

Tom_Ding@hotmail.com wrote:
Quote:
Hello all,
By using the SKILL function remd, I can remove some items of a
list. But how can I remove all the items of a list? In other words, how
can I make a list be empty?
Thanks.


Do you want to destructively make a list empty? Or just set a
variable to an empty list?
You could do something like the following:

(while (car some-list)
(remd (car some-list) some-list))

But if you just want to replace some-list with an empty list
you can use (some-list = nil)

What do you want to happen to other references to parts of
the list? for example

x = (list 1 2 3 4 5)
y = (cdr x)
z = (cons 0 x)

Note that y points to the list ( 2 3 4 5), but the same one
that (cdr x) points to. So if you do not care that y still
points to ( 2 3 4 5) you can do something more efficient
to x. This y unchanged, but sets z to the list ( 0)

(rplacd x nil)
(remd (car x) x)

-jim
Back to top
Guest






Posted: Tue Nov 16, 2004 1:02 pm    Post subject: Re: How can I remove all the items of a list? Reply with quote

Oh! I see.
Thanks a lot!

Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Cadence All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB