Well, topic's name is strange, but I do not know how to name it better.
The question is the following: I have some Tuple
type, for example T1 = Tuple{Int, Int, Float64}
. And I want to add more types inside curly brackets, for example, Tuple{String, Int, Int, Float64}
. Ideally it should be a function (or macros?) which do something like:
f(::Type{S}, ::Type{Tuple{???}}) = ??? # should produces Tuple{S, ???...}
May be from another angle, same question can be also asked like that. I have following structure
struct Foo{S, T <: Tuple}
x::S
y::T
end
And I want to have
Tables.schema(foo::Foo{S, T}) where {S, T} = Tables.Schema(names(foo), Tuple{S, T...})
Of course T...
is not working here, because it is a type.
f(::Type{S}, ::Type{T}) where {S,T<:Tuple} = Tuple{S,T.types...}
should do
julia> f(String, Tuple{Int64, Int64, Float64})
Tuple{String, Int64, Int64, Float64}
Ah, this is amazing, thank you!
I was so close :-))
Last updated: Nov 06 2024 at 04:40 UTC