11 lines
270 B
Text
11 lines
270 B
Text
def flatten(nested) {
|
|
def flat := [].diverge()
|
|
def recur(x) {
|
|
switch (x) {
|
|
match list :List { for elem in list { recur(elem) } }
|
|
match other { flat.push(other) }
|
|
}
|
|
}
|
|
recur(nested)
|
|
return flat.snapshot()
|
|
}
|