julia> foo(N) = NTuple{N,Int64}[]
foo (generic function with 1 method)

julia> foo(1)
0-element Array{(Int64,),1}

julia> foo(2)
0-element Array{(Int64,Int64),1}

julia> foo(3)
0-element Array{(Int64,Int64,Int64),1}


On Sun, Feb 23, 2014 at 5:02 PM, Michael Schnall-Levin
<[email protected]>wrote:

> I'm trying to figure out how to do the following, can someone help?
>
> Say I want to create an array of 2-tuples of Int64s, then I can just do:
> x = (Int64, Int64)[]
>
> But what if I want to create an array of N-tuples of Int64s, where N is
> set at run-time.  Is there a way to do this?
>
> The easiest thing to do seems to be just declare a broader type:
> x = Tuple[x]
>
> However, it seems like for type-checking and for performance, at times
> this may be sub-optimal.
>
> I was (perhaps naively) hoping some sort of type list-comprehension syntax
> might do the trick:
> x = (Int64 for n in 1:N)[]
>
> but this doesn't work.
>
> Any help would be very appreciated!
>

Reply via email to