Is this an example of tail recursion?
rosuav at gmail.com
Wed Aug 5 17:54:41 CEST 2015
On Thu, Aug 6, 2015 at 1:37 AM, <jennyfurtado2 at gmail.com> wrote:
> Sorry I am missing a subtle point: Isnt 1+ self.soldiersVsDefenders... ending up calling 1.__add__(self.soldiersVsDefenders...)?
I think his point is that it is, in effect, doing that; but honestly,
calling this a tail call into the int+int addition function is pretty
pointless. I mean, sure, it's technically a sort of tail call, but
it's definitely not tail recursion, and it's such a trivial operation
(adding one to a probably-small number) that it's hardly even worth
mentioning. The main point of tail recursion is how it interacts with
the self-call, and that's not the tail call here.
More information about the Python-list