Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to delete an array element?

0 views
Skip to first unread message

Piche Jean

unread,
Sep 24, 1995, 3:00:00 AM9/24/95
to

How does one get rid of an array element. It seems that once the array is created
all elements in it become permanent. You can change an element's value, but you
cant delete the element...

Any clues besides rewritting the whole array?

Thanks

JP

--
_____________________________________________________________________________
Jean Piche
Musique - UdM
pic...@ERE.Umontreal.ca

John Ellson

unread,
Sep 24, 1995, 3:00:00 AM9/24/95
to
In article <pichej.8...@mistral.ere.umontreal.ca>,

Piche Jean <pic...@ERE.UMontreal.CA> wrote:
>
>How does one get rid of an array element. It seems that once the array
>is created all elements in it become permanent. You can change an
>element's value, but you cant delete the element...

Use "unset" to delete an element, or any other variable.

% set a(1) one
one
% set a(2) two
two
% array names a
1 2
% unset a(2)
% array names a
1
%


John Ellson
AT&T Bell Labs
--
John....@att.com

Bill Semler

unread,
Sep 24, 1995, 3:00:00 AM9/24/95
to
In article <pichej.8...@mistral.ERE.UMontreal.CA>,
pic...@ERE.UMontreal.CA says...

>
>
>How does one get rid of an array element. It seems that once the array
is create
>d
>all elements in it become permanent. You can change an element's value,
but you
>cant delete the element...
>
>Any clues besides rewritting the whole array?
>
>Thanks
>
>JP
>
>--
>________________________________________________________________________
_____
> Jean
Piche
> Musique
- UdM
>
pic...@ERE.Umontreal.ca


try the unset command as in:

unset arrayname(elementname)

tcl takes care of the rest - simple, no?

Bill Semler
wse...@epix.net


Jeffrey Hobbs

unread,
Sep 24, 1995, 3:00:00 AM9/24/95
to
In article <pichej.8...@mistral.ERE.UMontreal.CA>,

Piche Jean <pic...@ERE.UMontreal.CA> wrote:
>How does one get rid of an array element.

unset works on array elements too. Just use 'unset ary(elem)'.
--
Jeffrey Hobbs Office: 503/346-3998
Univ of Oregon CIS GTF email: jho...@cs.uoregon.edu
URL: http://www.cs.uoregon.edu/~jhobbs/

Eric Vought

unread,
Oct 10, 1995, 3:00:00 AM10/10/95
to

> >all elements in it become permanent. You can change an element's value, but you
> >cant delete the element...
>
> >Any clues besides rewritting the whole array?
>
> This is just off the top of my head but why not
>
> set A(1) "hi there"
> set A(2) "all you folks"
>
> unset A(2)
>
> I can't verify this from home but that's my first thought. Any one else?

You CAN unset variables, array variables, and individual array elements
using unset.

set A foo
set B(foo)
set B(bar)
set B(baz)

unset A
unset B(foo)
unset B

All three of these work.

______________________________________________________________________
Warning: Due to the second Law of thermodynamics, use of your mail reader
may lead to the eventual heat death of the universe.


0 new messages