I saw people use ‘Val’ in their codes.
help?> ntuple
search: ntuple NTuple NamedTuple @NamedTuple UnitUpperTriangular
ntuple(f::Function, n::Integer)
Create a tuple of length n, computing each element as f(i), where i is the index of the element.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> ntuple(i -> 2*i, 4)
(2, 4, 6, 8)
────────────────────────────────────────────────────
ntuple(f, ::Val{N})
Create a tuple of length N, computing each element as f(i), where i is the index of the element. By taking a Val(N) argument, it is possible that this version of
ntuple may generate more efficient code than the version taking the length as an integer. But ntuple(f, N) is preferable to ntuple(f, Val(N)) in cases where N
cannot be determined at compile time.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> ntuple(i -> 2*i, Val(4))
(2, 4, 6, 8)
I am not sure about the meaning of ’ But ntuple(f, N) is preferable to ntuple(f, Val(N)) in cases where N cannot be determined at compile time.’
what does it mean that a variable can be determined at compile time, or that it cannot be determined at compile time but only at run time?