Closed avik-pal closed 3 weeks ago
This is more of a Julia syntax issue not a compact issue.
julia> map([[1], [2], [3]]) do x::AbstractVector{T} where {T}
@show T
return x
end
ERROR: UndefVarError: `T` not defined
Stacktrace:
[1] macro expansion
@ ./show.jl:1181 [inlined]
[2] (::var"#37#38")(x::Vector{Int64})
@ Main ./REPL[25]:2
[3] iterate
@ ./generator.jl:47 [inlined]
[4] _collect(c::Vector{Vector{Int64}}, itr::Base.Generator{Vector{Vector{Int64}}, var"#37#38"}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:854
[5] collect_similar(cont::Vector{Vector{Int64}}, itr::Base.Generator{Vector{Vector{Int64}}, var"#37#38"})
@ Base ./array.jl:763
[6] map(f::Function, A::Vector{Vector{Int64}})
@ Base ./abstractarray.jl:3285
[7] top-level scope
@ REPL[25]:1
[8] top-level scope
@ none:1
I would expect
N
to be accessible inside the function body.