Re: Snippet to remove an item from a list
Re: Snippet to remove an item from a list
- Subject: Re: Snippet to remove an item from a list
- From: Victor Yee <email@hidden>
- Date: Tue, 10 Jul 2001 14:31:14 -0400
On Tue, 10 Jul 2001 10:01:46 -0400, Arthur J Knapp wrote,
>
> That's the way I was doing it before... so much for left-wise thinking :(
>
>
I'm sorry, Victor, I wasn't attempting to supress left-wise thinking.
Don't worry, left-wise thinking will never be supressed. Speaking of which, where's R23?
>
I was just thinking in the same terms as Jeff Baumann, that the technique
>
that you proposed was slower than other list methods discussed on the
>
list before.
>
>
Your technique had the advantage of using AppleScript references, which
>
need to be better explored and utilized by us scripters.
But the concat method works on referenced lists just fine with a little modification:
on DeleteAt(lstRef, x)
if (x = 1) then
set lstRef's contents to lstRef's rest
else if (x = lstRef's length) then
set lstRef's contents to lstRef's items 1 thru -2
else
set lstRef's contents to (lstRef's items 1 thru (x - 1)) & ,
(lstRef's items (x + 1) thru -1)
end if
end DeleteAt
set thisList to {1, 2, 3, 4, 5}
set thisRef to a reference to thisList
DeleteAt(thisRef, 3)
thisList
--> {1, 2, 4, 5}
>
Has no one read the Hitchhicker's Guide to the Galaxy?
>
>
;-)
I will one day. As soon as I figure out how Saturn became a salad...
Victor