On 2009-01-26, at 04:46:47, Mark J. Reed wrote:
Why do all these solutions use globals? Is it a performance thing?
(Kneejerk: globals bad!)
You're correct. A better plan is to use a parameter for output.
In many cases though I believe there will be performance improvements using Serge/Garvey techniques or making it a script.
on FlattenList(theList, outResult)
repeat with i in theList
if (class of i is list) then
my FlattenList(i, outResult)
else
set end of outResult to contents of i
end if
end repeat
end FlattenList
set deep to {{"item 1", 0, {"item 3", "item 4", "item 5"}}, {{name:"Michael"}, "item 7", "item 8"}, 999}
set outResult to {}
my FlattenList(deep, outResult)
outResult