Generator sometimes works, sometimes not

It’s unrelated to syntax and parsing. findall is documented to only work on things with indices or keys that work with the methods keys and pairs. Zip-ped generators currently don’t, but if someone implements keys method, it could. On the other hand, minimum is documented to work with iterators (by implication of its argument name itr, so not very formally), which all generators should be.

Just in case, bear in mind that you can get away with omitting the parentheses for generator expressions in function calls when it’s the only argument before ;. If there are other arguments, proper syntax demands those parentheses, and the consequences are unfortunately silent:

julia> sum(i for i in 1:10)
55

julia> sum(i for i in 1:10, init=100) # parsed as 2-level nested loop
55

julia> sum((i for i in 1:10), init=100) # parsed as 2 arguments
155

julia> sum(i for i in 1:10; init=100) # ; not in loops, so parsed as 2 arguments
155
5 Likes