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, 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) > > julia> f(Tuple) > (Vararg{Any,N},julia> f(Tuple{Int64, Float64}) > (Int64,Float64) > > Probably has crappy performance though. > > 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, Float32}) --> (Int64, MyType, Float32) > > f(NTuple{3}) --> (Any, Any, Any) > > f(Tuple) --> Some error since > > length is unknown > > ``` > > > > How to accomplish this?