TupleTools.jl icon indicating copy to clipboard operation
TupleTools.jl copied to clipboard

Definition of tail2

Open cossio opened this issue 5 years ago • 4 comments

https://github.com/Jutho/TupleTools.jl/blob/ad34513fb3644f6e58741358252e457461dba113/src/TupleTools.jl#L37

Can someone explain why tail2 is defined in such a complicated way?

Why not just tail2(t::Tuple) = tail(tail(t))?

cossio avatar Apr 06 '20 22:04 cossio

I don't remember; I just copied how Base implements tail.

Jutho avatar Apr 06 '20 22:04 Jutho

ok. Just wondering if there was deep reason.

cossio avatar Apr 07 '20 08:04 cossio

Not sure if both would generate the same machine code; that's easy to check.

Jutho avatar Apr 07 '20 08:04 Jutho

Just checked, and tail(tail(t)) generates the same machine code as tail2(t). Maybe the simpler implementation is indeed less confusing.

In general, I have recently used TupleTools a bit less, due to the good broadcasting support of tuples.

Jutho avatar Apr 07 '20 08:04 Jutho