Re: Is this an example of tail recursion?

2015-08-05 Thread Chris Angelico
On Thu, Aug 6, 2015 at 2:51 AM, Rustom Mody wrote: > And I continue to have no idea what Chris is talking about. > Here is C printf from ctypes import * cdll.LoadLibrary("libc.so.6") libc = CDLL("libc.so.6") libc.printf(b"%s", b"Hello") > 5 > Hello>>> > > As far as I can see pr

Re: Is this an example of tail recursion?

2015-08-05 Thread Rustom Mody
On Wednesday, August 5, 2015 at 10:11:30 PM UTC+5:30, wrote: > On Wednesday, August 5, 2015 at 10:29:21 AM UTC-6, Chris Angelico wrote: > > On Thu, Aug 6, 2015 at 2:10 AM, Rustom Mody wrote: > > > 1 + x > > > does not *call* 1 .__add__(x) > > > It *is* that > > > [Barring corner cases of radd etc

Re: Is this an example of tail recursion?

2015-08-05 Thread jennyfurtado2
On Wednesday, August 5, 2015 at 10:29:21 AM UTC-6, Chris Angelico wrote: > On Thu, Aug 6, 2015 at 2:10 AM, Rustom Mody wrote: > > 1 + x > > does not *call* 1 .__add__(x) > > It *is* that > > [Barring corner cases of radd etc] > > IOW I am desugaring the syntax into explicit method-calls so you can

Re: Is this an example of tail recursion?

2015-08-05 Thread Chris Angelico
On Thu, Aug 6, 2015 at 2:10 AM, Rustom Mody wrote: > 1 + x > does not *call* 1 .__add__(x) > It *is* that > [Barring corner cases of radd etc] > IOW I am desugaring the syntax into explicit method-calls so you can see > all the calls explicitly > Then it becomes evident -- visibly and in fact --th

Re: Is this an example of tail recursion?

2015-08-05 Thread jennyfurtado2
On Wednesday, August 5, 2015 at 10:10:22 AM UTC-6, Rustom Mody wrote: > On Wednesday, August 5, 2015 at 9:07:52 PM UTC+5:30, jennyf...@gmail.com > wrote: > > On Wednesday, August 5, 2015 at 9:21:33 AM UTC-6, Rustom Mody wrote: > > > On Wednesday, August 5, 2015 at 8:43:31 PM UTC+5:30, jennyf...@gm

Re: Is this an example of tail recursion?

2015-08-05 Thread Rustom Mody
On Wednesday, August 5, 2015 at 9:07:52 PM UTC+5:30, jennyf...@gmail.com wrote: > On Wednesday, August 5, 2015 at 9:21:33 AM UTC-6, Rustom Mody wrote: > > On Wednesday, August 5, 2015 at 8:43:31 PM UTC+5:30, jennyf...@gmail.com > > wrote: > > > I am trying to learn differences between tail recursi

Re: Is this an example of tail recursion?

2015-08-05 Thread jenny
On Wednesday, August 5, 2015 at 9:52:14 AM UTC-6, Chris Angelico wrote: > On Thu, Aug 6, 2015 at 1:13 AM, wrote: > > I am trying to learn differences between tail recursion and non tail > > recursion. > > Tail recursion is where you do exactly this: > > return some_function(...) > > Absol

Re: Is this an example of tail recursion?

2015-08-05 Thread Chris Angelico
On Thu, Aug 6, 2015 at 1:37 AM, 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 fu

Re: Is this an example of tail recursion?

2015-08-05 Thread Chris Angelico
On Thu, Aug 6, 2015 at 1:13 AM, wrote: > I am trying to learn differences between tail recursion and non tail > recursion. Tail recursion is where you do exactly this: return some_function(...) Absolutely nothing is allowed to happen around or after that function, and that also means you

Re: Is this an example of tail recursion?

2015-08-05 Thread jennyfurtado2
On Wednesday, August 5, 2015 at 9:21:33 AM UTC-6, Rustom Mody wrote: > On Wednesday, August 5, 2015 at 8:43:31 PM UTC+5:30, jennyf...@gmail.com > wrote: > > I am trying to learn differences between tail recursion and non tail > > recursion. > > > > Is the following recursive code tail recursive?

Re: Is this an example of tail recursion?

2015-08-05 Thread Rustom Mody
On Wednesday, August 5, 2015 at 8:43:31 PM UTC+5:30, jennyf...@gmail.com wrote: > I am trying to learn differences between tail recursion and non tail > recursion. > > Is the following recursive code tail recursive? > If it is not how to convert it to tail recursion? > If it is how to convert it