Tail recursion

"jjb" <Alexey.Mikhailov@gmail.com>
4 Nov 2006 18:44:42 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: Tail recursion danwang+news@cs.princeton.edu (Daniel C. Wang) (2000-08-14)
Re: Tail recursion toon@moene.indiv.nluug.nl (Toon Moene) (2000-08-14)
Re: Tail recursion fjh@cs.mu.OZ.AU (2000-08-21)
Re: Tail recursion Wilco.Dijkstra@arm.com (Wilco Dijkstra) (2000-08-21)
Re: Tail recursion mrs@kithrup.com (2000-08-21)
Re: Tail recursion ian0kerr@my-deja.com (2000-09-08)
Tail recursion Alexey.Mikhailov@gmail.com (jjb) (2006-11-04)
Re: Tail recursion kym@ukato.freeshell.org (russell kym horsell) (2006-11-04)
Re: Tail recursion diablovision@yahoo.com (2006-11-05)
Re: Tail recursion owong@castortech.com (Oliver Wong) (2006-11-08)
Re: Tail recursion jboehm@gmx.net (=?ISO-8859-1?Q?J=FCrgen_B=F6hm?=) (2007-02-04)
| List of all articles for this month |

From: "jjb" <Alexey.Mikhailov@gmail.com>
Newsgroups: comp.compilers
Date: 4 Nov 2006 18:44:42 -0500
Organization: Compilers Central
Keywords: optimize, question
Posted-Date: 04 Nov 2006 18:44:42 EST


Recently I read about "tail recursion" (in SICP) - ability of
programming language realization to convert linear recursive proccess
to linear iterative proccess. So I tried to find formal algorithm of
this transformation for any function written using functional paradigm
but I failed. May be someone can help me?

Some trivial example here is calculating factorial.

Linear recursive:
fact n = if (n < 3) then n else (n * fact(n-1))

Linear iterative:
fact n = fact-iter 1 1 n
fact-iter product counter max-count = if (counter > max-count) then

                                    else (fact-iter (counter*product) (counter+1)

Thanks in advance!

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.