Tail-recursion means some method calls itself and then simply returns whatever the call to itself returns. Once you don’t simply return the returned value, but instead use it to create a new value, it is no longer tail-recursion.
In your case, tailFac
does not simply return the result of calling itself. Inside tailFac
, the call to tailFac
returns a lambda object, which is then called and the result of that call is wrapped into a new lambda object. To make it tail recursive, you would have to return the exact lambda object returned by the inner call.