Re: Flattening Nested Lists
Re: Flattening Nested Lists
- Subject: Re: Flattening Nested Lists
- From: Barry Wainwright <email@hidden>
- Date: Mon, 26 Jan 2009 09:52:27 +0000
On 26 Jan 2009, at 09:30, Rick Gordon wrote:
I'm spending too much time trying to do something that I think
should be easy enough: flattening a list of lists (of lists (of
lists)), so that the the result is a list containing no list
elements. Can someone point me to some code or instruction on
handling this? I'm figuring that it probably takes a recursive
handler, but I'm getting recursed in my own mind, at this point.
--
set aList to {{"item 1", "item 2", {"item 1", "item 2", "item 3"}},
{"item 1", "item 2", "item 3"}, "item 3"}
set newList to {}
my flattenList(aList)
newList
on flattenList(theList)
global newList
repeat with anItem in theList
if class of anItem is list then
my flattenList(anItem)
else
copy anItem to end of newList
end if
end repeat
end processList
--
Barry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden