2 ms·
Not scared of Haskell, just we have other ways to do stuff like this in C++, namely iterators. I posted a solution using iterators here: https://news.ycombinat
by jzwinck 13y ago
Not scared of Haskell, just we have other ways to do stuff like this in C++, namely iterators. I posted a solution using iterators here: https://news.ycombinator.com/item?id=7626984 https://news.ycombinator.com/item?id=7626984
My solution completely avoids dynamic memory allocation--even the stack allocation is just a handful of bytes per generated triple.
You're right that lazy evaluation is useful for performance, but TFA acknowledges that its own implementation is not efficient because it dynamically allocates memory repeatedly. This is not something we can hand-wave away: it's at the core (no pun intended) of high performance in C++ and many other languages.