How to kill the content of a list instead of the list itself?



On Wed, Dec 29, 2010 at 09:20, Stefano Ferri <ferriste at gmail.com> wrote:

>
> I think you have to take into account, that the symbols evaluate to
>> their numerical value.
>>
>
> Thank you, maybe I've made a bit of confusion about this point... But there
> is still an issue: if a, b and c are contained in an unnamed list [a, b, c]
> they can be killed by apply(kill,'[a,b,c]), and this is clear. The problem
> comes when the list [a,b,c] is assigned to a variable:
>
> mylist : [a,b,c]
>
> The only solution I've found is this: mylist must either be defined before
> assigning a value to a, b and c, or defined as
>
> mylist : '[a, b, c]
>

Exactly right.


> then apply(kill, mylist) works fine.
>
> But I have the problem that mylist may already exist and contain every type
> of argument, with assigned values or not, and I have to kill its arguments,
> without killing and possibly without empty the list itself...
>

If you assigned mylist:[a,b,c] at a time when a,b,c already have values,
then the list mylist does not contain the names a,b,c at all, just their
values.


> For example, if mylist : [a, b, c]
>
> 'mylist;
> [a,b,c]
>

NO!  'mylist here evaluates to the symbol mylist.

mylist;
> [1,2,3]
>
>
> a;
> 1
>
> b;
> 2
>
> c;
> 3
>
> I should be able to kill a,b,c but without touching the list. After all I
> should get:
>
> some command to kill....
>
> 'mylist;
> [a,b,c]
>

WRONG!


> mylist;
> [a,b,c]
>
> a;
> a
>
> b;
> b
>
> c;
> c
>
>
> I hope that the problem is clear now... Thanks for patience :-)
>
> Stefano
>
>
>