• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing items from a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing items from a list


  • Subject: Re: Removing items from a list
  • From: Michael Terry <email@hidden>
  • Date: Sat, 6 Mar 2004 15:51:50 -0800

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.


  • Follow-Ups:
    • Re: Removing items from a list
      • From: Christopher Nebel <email@hidden>
    • Re: Removing items from a list
      • From: Steve Meyer <email@hidden>
References: 
 >Removing items from a list (From: Michelle Steiner <email@hidden>)
 >Re: Removing items from a list (From: Steve Meyer <email@hidden>)

  • Prev by Date: Re: Removing items from a list
  • Next by Date: The other Folder Action handlers
  • Previous by thread: Re: Removing items from a list
  • Next by thread: Re: Removing items from a list
  • Index(es):
    • Date
    • Thread