How to kill the content of a list instead of the list itself?
Subject: How to kill the content of a list instead of the list itself?
From: Dieter Kaiser
Date: Wed, 29 Dec 2010 11:48:57 +0100
Am Mittwoch, den 29.12.2010, 11:33 +0100 schrieb Stefano Ferri:
> Thanks for you reply, but that command doesn't work. Actually, apply
> or even a do loop on a list have no effect.
>
> For example:
>
> for i in mylist do kill(i);
>
> doesn't kill anything... why?
I think you have to take into account, that the symbols evaluate to
their numerical value. This shows the problem and a possible solution:
(%i16) a:1;b:2;c:3;
(%o16) 1
(%o17) 2
(%o18) 3
(%i19) [a,b,c];
(%o19) [1, 2, 3]
(%i20) '[a,b,c];
(%o20) [a, b, c]
(%i21) apply(kill, '[a,b,c]);
(%o21) done
(%i22) [a,b,c];
(%o22) [a, b, c]
Dieter Kaiser