This is exactly what `NTuple` was designed for:
julia> NTuple{3,Float64}
(Float64,Float64,Float64)
You can use this as a field in a parametric type
julia> type Foo{N}
x::NTuple{N,Float64}
end
julia> Foo((1.0,2.0,3.0))
Foo{3}((1.0,2.0,3.0))
On Tuesday, 28 October 2014 15:47:56 UTC, Andrew Gibb wrote:
>
> Is there a way to create a parameterised type where the parameter
> describes the number of items, ie
> type Thing{N<:Integer}
> for i = 1:N
> a_i::Float64
> end
> end
>
> I realise one could achieve this simple example with an array, but I'm
> trying to create a type which holds scale space. My current thinking is
> this would consist of a parameterisable number of images each with a
> parameterisable number of layers. And each image in the sequence has the
> two spatial dimensions (not the number of layers) reduced by a factor of
> two.
>
> I guess you cold do some tricks with array packing, but I guess I'm
> looking for something more elegant. Is there any way to use the type
> parameter to indicate a number of elements in this way?
>
> Andy
>