I need to define a tuple of n elements ie (1,2,3,…,n)
where n is the argument of function f as below
function f(n)
…
None of the following work
x=(1,2,3,…,n)
x=(i, i=1:n)
…
end
I need to define a tuple of n elements ie (1,2,3,…,n)
where n is the argument of function f as below
function f(n)
…
x=(1,2,3,…,n)
x=(i, i=1:n)
…
end
You can use ntuple
or a generator comprehension:
julia> ntuple(n -> n, 10)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
julia> Tuple(i for i in 1:10)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Thanks @Mason, really appreciate the help. It works perfectly. I had struggled with this for a while.