Re: Removing items from a list
Re: Removing items from a list
- Subject: Re: Removing items from a list
- From: Steve Meyer <email@hidden>
- Date: Sat, 6 Mar 2004 18:08:08 -0700
Thank you. Very interesting.
Some comments. The actual max list size varies with the content. It's
about 250 items within the types I tried. Less for {"1"} which aren't
in theSet below, more for 1, for which all items are deleted in the
example below.
This definitely limits my interest in the recursion method, since it's
not a complete solution. Is this common knowledge and widely avoided?
Regarding your 'Curious' section below - I'm not sure what point you're
making(?)
Steve
On Mar 6, 2004, at 4:51 PM, Michael Terry wrote:
On Mar 6, 2004, at 2:35 PM, Steve Meyer wrote:
Using recursion and the remarkable "rest of" command, and directly
plagiarizing Matt Neuburg and AS:The Definitive Guide (page 153):
The only problem with using recursion in AS like folks do in Lisp is
that one quickly runs into stack overflow errors.
on newListOfSize(len, filler)
set lst to {filler}
repeat until (count lst) > len
set lst to lst & lst
end repeat
return lst's items 1 thru len
end newListOfSize
on deleteItems(theSet, DeleteThese)
if theSet = {} then return theSet
if item 1 of theSet is in DeleteThese then
return deleteItems((rest of theSet), DeleteThese)
else
return {item 1 of theSet} & deleteItems((rest of theSet),
DeleteThese)
end if
end deleteItems
set x to newListOfSize(500, 1)
set x's end to "1"
deleteItems(x, {"1"})
-- on my machine, errors with a stack overflow
My brother told me this must mean that AS isn't tail-end recursive or
something. However, I don't know what that means.
Mike
Curious:
--
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopq
rstuvwxyz{|}~
!"#
$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTU
VWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.