I would like to create a function taking two tuples t1
and t2
as arguments. The two tuples need to have the same length, but their elements can be of any type, and each tuple doesn’t need to be composed of the entries of the same type (i.e., the tuples can be inhomogeneous). An example satisfying this condition would be t1 = (1, 1.0, true)
and t2 = (zeros(3), "abc", 1//2)
.
Is it possible to specify the argument types enforcing this condition? I thought
function myfun(t1::NTuple{N}, t2::NTuple{N}) where {N}
would do the job, but it seems that ::NTuple
expects a homogeneous tuple (i.e., a tuple composed of entries of the same type).