Thanks David, that gets me part of the way there but is there a way of
specifying the x argument as a varag so that the function can be called as:
f(1, 2, 3) rather than f((1, 2 , 3)) this is useful if I am trying to
"lift" a bunch of functions that already exist to play with new types. For
instance I could then call plus on the new types T1(value1) + T2(value2)
retaining the natural semantics of the functions.
DP
On Monday, October 5, 2015 at 12:03:33 AM UTC+1, David Gold wrote:
>
> Note that if the type variable T does not appear in the argument signature
> then the method won't be callable.
>
> If you really want to make use of the variable parameters, your best bet I
> think is to pass a tuple of args:
>
> function f{T<:Tuple}(x::T)
> for (i, param) in enumerate(T.parameters)
> println(typeof(x[i]) <: param)
> end
> end
>
> This (or some variant, I forget) can also make the types of the individual
> xs available at compile time.
>
>
>
> On Saturday, October 3, 2015 at 7:22:49 PM UTC-7, [email protected]
> wrote:
>>
>> Is it possible to specify a variable number of parameter types in Julia,
>> for instance something like
>>
>> function {T...}my_fun(x...)
>> for i in 1:length(x)
>> println(typeof(x[i]) <: T[i])
>> end
>> end
>>
>> should print true ... times
>>
>> Thanks
>>
>