3 ms·
Like others have pointed out you should have used recursion. Although, if you really wanted to you can make one similar to yours that doesn't (explicitely) use
by contravariant 10y ago
Like others have pointed out you should have used recursion. Although, if you really wanted to you can make one similar to yours that doesn't (explicitely) use recursion. That results in the following:
flatten = (lambda f: lambda *args:
(lambda x: lambda *args2: f(x(x))(*args2))
(lambda x: lambda *args2: f(x(x))(*args2))(*args))(
lambda f: lambda l: [item for sublist in l for item in f(sublist)] if isIterable(l) else [l]
)