Closed
Description
When I do the following:
v = SA[10, 20, 30]
map(x -> x[1] + x[2], enumerate(v))
The result is a 3-element Vector{Int64}
of values 11, 22 and 33. Is it possible to get the result in SVector
since the length is known at compile time (assuming that the codes above is inside a function, and that v
has fixed but unknown length)?
Other methods I tried but not did not work:
- I tried to use comprehension and macro
@SVector
, but it seems that in this case I needlength(v)
but its value is unknown during macro expansion. - I also tried
eachindex(v)
but it seems that the result is converted toMVector
instead ofSVector
. This part seems to have been covered in map SOneTo to SVector #1032
Metadata
Metadata
Assignees
Labels
No labels