Typed and Untyped Comprehensions

Hi everyone,

What are typed and untyped comprehensions and what are syntax forms of those?

Thanks in advance.

Does the info here: https://docs.julialang.org/en/stable/manual/arrays/#Comprehensions-1 help?

Can there be dictionary based comprehensions?
is so can you give me an example?

Thanks

julia> ex = :([x^2 for x in 0:9 if x>5])
:([x ^ 2 for x = 0:9 if x > 5])

julia> ex.head
:comprehension

julia> ex.args
1-element Array{Any,1}:
 :((x ^ 2 for x = 0:9 if x > 5))

julia> ex.args[1]
:((x ^ 2 for x = 0:9 if x > 5))

julia> ex.args[1].head
:generator

julia> ex = :(Int[x^2 for x in 0:9 if x>5])
:(Int[x ^ 2 for x = 0:9 if x > 5])

julia> ex.head
:typed_comprehension

I see :compherension and :typed_compherension can there be any more head symbols related to comprehensions?

How can i learn that?
Thanks

Might be some useful stuff here: https://docs.julialang.org/en/latest/devdocs/ast/#Bracketed-forms-1

1 Like

Is generator missing from that table, or does it belong elsewhere?