From: Jonathan Bryant <jtbryant@valdosta.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Mututal Recursion and Tail Recursion
Date: Fri, 15 Jul 2005 08:15:33 -0400 [thread overview]
Message-ID: <1121429733.25450.5.camel@starlight.valdosta.edu> (raw)
In-Reply-To: <17111.23105.448745.536629@gargle.gargle.HOWL>
Ok, I don't know enough about assembly to know exactly what that means,
although I think that you mean they are tail recursive. The whole
reason I wrote this tiny module was to do that tail recursive since the
List module isn't. How does one submit code updates to INRIA for things
like this?
On Fri, 2005-07-15 at 08:40 +0200, Jean-Christophe Filliatre wrote:
> Jonathan Bryant writes:
> > Is is possible to have mutually recursive functions that are also tail
> > recursive?
>
> Yes.
>
> > For example, attached is some code I wrote to flatten a list
> > of lists using mutually recursive functions. I've tried this with large
> > lists (5,000,000+) and have not encountered a stack overflow, but that
> > does not necessarily mean that tail recursion is happening.
>
> Looking at the assembly code (obtained with "ocamlopt -S") clearly
> gives the answer: all three recursive calls in flat_in and flat_out
> are realized by jumps (and not calls).
>
> I copy below the assembly code for the functions flat_in and flat_out.
>
> Hope this helps,
--
*=========================*
|Jonathan Bryant |
|Valdosta State University|
|Information Technology |
|System Operations |
|-------------------------|
|jtbryant@valdosta.edu |
|x6358 |
*=========================*
next prev parent reply other threads:[~2005-07-15 12:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-13 19:03 Jonathan Bryant
2005-07-15 6:40 ` [Caml-list] " Jean-Christophe Filliatre
2005-07-15 12:15 ` Jonathan Bryant [this message]
2005-07-18 0:56 ` Jacques Garrigue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1121429733.25450.5.camel@starlight.valdosta.edu \
--to=jtbryant@valdosta.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox