3 ms·
In the Haskell case you could also do something like this to avoid needing that optimisation: map (f . g . h) someList And in Python 3, map returns an itera
by koenigdavidmj 14y ago
In the Haskell case you could also do something like this to avoid needing that optimisation:
map (f . g . h) someList
And in Python 3, map returns an iterator, not a list, so you aren't building the full list until you ask for it, and you never build intermediate lists in your example. You can do the same thing in Python 2 with the itertools.imap function.
- dons 14y ago`map` is the trivial case. There are plenty of loop compositions that are completely non-trivial to do by hand. That's why array fusion (see e.g. repa or vector) is a huge win. foldl g . scanl y . concatMap x . filter h . unfoldr k Fuse that by hand. This is why we have optimizing compilers. They do what you could have done, only more often, and without mistakes.