Perhaps I've just missed it, but I can't seem to see any trace of the List.flatten() function in the github repo. It is in the source downloaded form pypi.
Hi embr, it has been removed in this commit: bc37e58
Reason being that I wanted to keep the library a small as possible and since moka allows any operations on its list, it's easy to flatten it. Maybe since flatten isn't trivial I should consider adding it back.
Understandable. I think it would be simple to do if there were some sort of reduce method available (have I just missed that, btw?). But as it stands, I can't see a way to update the entire list through a user defined function. That is, you can change each element in place, but you can't change the whole list in place. Thanks for response.
Actually, there's the "do" that let you do whatever you want with the list:
>>> x = List([1,2,3]).do(lambda self: List(reversed(self)))
[3, 2, 1]
You have to wrap the return object with a call to Moka.List if you plan to continue the chaining however.
That being said I had 'fold' in my todo list so it really was an oversight.
Thanks for bringing it up.
I see. I had tried that earlier with the pypi version, but as you may know, that version's do() doesn't store the result of the function back to self but just allows you to add side effects. Thanks for the responses.