[julia-users] Re: Tuple type to tuple of types

2016-07-26 Thread jw3126
Thanks! On Sunday, July 24, 2016 at 1:52:47 PM UTC+2, jw3126 wrote: > > I need a function, which accepts an arbitrary tuple type and returns the > types of the components of the tuple. For example > ``` > f(Tuple{Int64, Float64})--> (Int64, Float64) > f(Tuple{Int64, MyType,

Re: [julia-users] Re: Tuple type to tuple of types

2016-07-24 Thread Tim Holy
As long as you don't mind preserving exactly what's between the {}, (t.parameters...) is an easy way to get this. --Tim On Sunday, July 24, 2016 5:21:56 AM CDT Kristoffer Carlsson wrote: > Maybe; > > type MyType end > > function f(t::DataType) > I = () > for t in t.types > if isa(t,

[julia-users] Re: Tuple type to tuple of types

2016-07-24 Thread David P. Sanders
El domingo, 24 de julio de 2016, 7:52:47 (UTC-4), jw3126 escribió: > > I need a function, which accepts an arbitrary tuple type and returns the > types of the components of the tuple. For example > ``` > f(Tuple{Int64, Float64})--> (Int64, Float64) > f(Tuple{Int64, MyType,

[julia-users] Re: Tuple type to tuple of types

2016-07-24 Thread Kristoffer Carlsson
Maybe; type MyType end function f(t::DataType) I = () for t in t.types if isa(t, TypeVar) I = (I..., Any) else I = (I..., t) end end return I end julia> f(Tuple{Int64, Float64}) (Int64,Float64) julia> f(Tuple{Int64, MyType, Float32}) (Int64,MyType,Float32) julia> f(NTuple{3}) (Any,Any,Any)