Here is example Julia code that reverses element of touple that I’m trying to understand. It must be my lack of experience but it’s extremely confusing to me why this is working at all.
revargs() = () revargs(x, r...) = (revargs(r...)...,x) reverse(t::Tuple) = revargs(t...)
julia> data = (1,2,3,4) (1,2,3,4) julia> reverse(data) (4,3,2,1)
I’m trying to understand two things:
- how … operator works here to produce reversed result.
- why it it necessary to define revargs() = () even though it does not look like it is being called to produce the result of reverse(data)
Can you please explain to me what happens step by step after I call reverse(data)?
I’m sorry if my question is to broad or unclear but i’m really stuck and don’t know how to find the answer.