procedure flatten(L) # in the spirt of the problem a structure local l,x l := [] every x := !L do if type(x) == "list" then l |||:= flatten(x) else put(l,x) return l end