Why do some functions not output the result directly?

Lazy computation can be really nice. For a simple example, consider

for (i,j) in IterTools.product(collect(1:5), collect(1:5))
    f(i,j)
end

Since this is lazy, we don’t have to allocate a ton of memory for no reason. Giving the result eagerly would just be slower.

6 Likes