# Tuple with unknown n elements

**URL:** <https://discourse.julialang.org/t/tuple-with-unknown-n-elements/37249>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 8, 2020, 10:01pm UTC](https://discourse.julialang.org/t/tuple-with-unknown-n-elements/37249 "2020-04-08T22:01:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Locust](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Locust](https://discourse.julialang.org/u/Locust)\
**Post date:** [April 8, 2020, 10:01pm UTC](https://discourse.julialang.org/t/tuple-with-unknown-n-elements/37249/1 "2020-04-08T22:01:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 8, 2020, 10:07pm UTC](https://discourse.julialang.org/t/tuple-with-unknown-n-elements/37249/2 "2020-04-08T22:07:47Z")

</div>

You can use `ntuple` or a generator comprehension:

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![Locust](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Locust](https://discourse.julialang.org/u/Locust)\
**Post date:** [April 8, 2020, 10:27pm UTC](https://discourse.julialang.org/t/tuple-with-unknown-n-elements/37249/3 "2020-04-08T22:27:10Z")

</div>

Thanks @Mason, really appreciate the help. It works perfectly. I had struggled with this for a while.
