Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Flatten-a-list/AppleScript/flatten-a-list-4.applescript
Normal file
26
Task/Flatten-a-list/AppleScript/flatten-a-list-4.applescript
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
on flatten(theList)
|
||||
script o
|
||||
property flatList : {}
|
||||
|
||||
-- Recursive handler dealing with the current (sub)list.
|
||||
on flttn(thisList)
|
||||
script p
|
||||
property l : thisList
|
||||
end script
|
||||
|
||||
repeat with i from 1 to (count thisList)
|
||||
set thisItem to item i of p's l
|
||||
if (thisItem's class is list) then
|
||||
flttn(thisItem)
|
||||
else
|
||||
set end of my flatList to thisItem
|
||||
end if
|
||||
end repeat
|
||||
end flttn
|
||||
end script
|
||||
|
||||
if (theList's class is not list) then return theList
|
||||
o's flttn(theList)
|
||||
|
||||
return o's flatList
|
||||
end flatten
|
||||
Loading…
Add table
Add a link
Reference in a new issue