That is only because Elixir pipes into the first arg instead of the last as is normal functional design (and of which ‘most’ erlang libraries follow the standard functional design of putting the ‘structure’ argument in last place, Elixir is the odd one out. ;-)).
Probably slower actually. Simple list manipulation like this is so simple (and the :lists.reverse
native function is so fast) that the overhead of a NIF would likely exceed the calls as they are now.
Ahh so true, I remember those younger Erlang days. ^.^;
I don’t know if I’m more lazy or what, but I use zippers themselves in those places. I should make a proper zipper library sometime…
I’ve made/used gap buffers in C++, and I don’t think they’d fit in as well here, they rely on mutability in their standard designs. You could make one that is not but it would end up being slower. A zipper basically is the functional form of one anyway with limitations so mutability is not needed.
/me loves zippers, uses them surprisingly often