RosettaCodeData/Task/Flatten-a-list/Logo/flatten-a-list.logo
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

13 lines
350 B
Text

to flatten :l
if not list? :l [output :l]
if empty? :l [output []]
output sentence flatten first :l flatten butfirst :l
end
; using a template iterator (map combining results into a sentence)
to flatten :l
output map.se [ifelse or not list? ? empty? ? [?] [flatten ?]] :l
end
make "a [[1] 2 [[3 4] 5] [[[]]] [[[6]]] 7 8 []]
show flatten :a