Re: deleting list components


[Prev][Next][Index][Thread]

Re: deleting list components



There is a simpler way to do just what the person asked about(deleting one
item), although I like RWW Taylor's suggestion, which allows you to delete
multiple items.

To remove one item:

{1,2,3,4,5,6,7,8,9,10} -> L1    // The initial list
7 -> N          // Where N is the position of the item you want to remove

For(X,N,dim(L1)-1)
        L1(X+1) -> L1(X)
End

dim(L1)-1 -> dim(L1)  //Cut the last item off of the list.


What this basically does is slide all the values past the position you want to
delete over one position, then cuts the last item(which after the loop is
equal to the original last item) off.  This will work for all N values between
1 and the length of the list(including the last value)

Hope this helps,

Vincent Fiduccia


Follow-Ups: