next up previous contents
Next: Cartesian products Up: Common data structures Previous: Using if-then statements   Contents

Removing elements from a list

First, something funny (funny/strange, not funny/haha):

> L:=[];                             
> L[3]:=10;
> Remove(~L,1);
> L[3];

>> L[3];
    ^
Runtime error in '[]': Sequence element 3 not defined
> L[2];
10
> L[1];

>> L[1];
    ^
Runtime error in '[]': Sequence element 1 not defined

MAGMA has deleted L[1]; (which wasn't even defined), and changed L[2] to L[1] (which wasn't even defined), changed L[3] to L[2]!

Exercise 7   Using the Reverse command, find the sequence of integers from $20$ down to $-20$. Using the Exclude command, remove from that set the element $0$.



David Joyner 2001-08-22