Brian Palmer wrote:
Andrei Alexandrescu Wrote:
[snip snip] Yah, I'll look into it. One thing is that not that many
functions will end up being lazy. For example, reduce is eager (I
think it's uninteresting to have it default to laziness).
Actually if I can pick a nit real quick here, I disagree that a lazy
reduce isn't interesting, there's a lot of very interesting
algorithms based off of lazy folding, and lazy folding of infinite
lists. After all, the fold is the "mother" of all those other
iterators like map, filter, etc. In any case, it sounds like
implementing a lazy reduce should be simple enough even if it's not
in std.algorithm itself, so I'm not set on it.
Exactly. Lazy reduce is easy to implement e.g. by means of a delegate.
On the other hand, lazy map is unimplementable from eager map.
Andrei