After Erlang/OTP R12B, a body-recursive function generally uses the same amount of memory as a tail-recursive function and generally hard to predict whether the tail-recursive or the body-recursive version will be faster.
With around 10, 000 elements, a body-reclusive function is about 10% faster. But with larger lists (like 10, 000, 000 elements), a body-reclusive function is about 97% lower and it is about as faster as the standard library map.
Myth: Tail-Recursive Functions are Much Faster Than Recursive Functions
TAIL CALL OPTIMIZATION IN ELIXIR & ERLANG – NOT AS EFFICIENT AND IMPORTANT AS YOU PROBABLY THINK
Wow that is interesting indeed, thanks for sharing!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.