El domingo, 4 de octubre de 2015, 15:45:19 (UTC-5), [email protected]
escribió:
>
> Hi Tom,
>
> I am looking for something analogous to a C++ variadic template function
> where the types as well as the arguments to the function are varags. These
> are aligned so that in my above notation T... would be a tuple/array of
> types corresponding to the types of x... and so each T[i] could be
> arbitrary.
>
You can just use a tuple of types:
julia> function my_fun(types, xx)
for (T, x) in zip(types, xx)
println(typeof(x) <: T)
end
end
my_fun (generic function with 1 method)
julia> my_fun((Float64, Int), (0.3, 1))
true
true
>
>
>
> DP
>
> On Sunday, October 4, 2015 at 4:30:19 AM UTC+1, Tom Breloff wrote:
>>
>> I think maybe the function you're looking for is something like:
>>
>> function my_fun(::Type{T}, x...)
>> for xi in x
>> println(typeof(xi) <: T)
>> end
>> end
>>
>> or some variation of that?
>>
>> On Sat, Oct 3, 2015 at 5:18 PM, <[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
>>>
>>
>>