Some python 2
def flatten(x):
def flatten_generator(x):
if type(x) == list:
for y in x:
for z in flatten(y):
yield z
else:
yield x
return list(flatten_generator(x))
assert(flatten([1, [2,3]]) == [1,2,3])
ary = [1, [2,3], [4, [5,6]]]
print flatten(ary)