Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Edgar Friendly <thelema314@gmail.com>
To: Brian Hurt <bhurt@janestcapital.com>
Cc: Kuba Ober <ober.14@osu.edu>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] [NEWBIE] is there an in-place map?
Date: Wed, 02 Jan 2008 13:20:57 -0600	[thread overview]
Message-ID: <477BE419.8080400@gmail.com> (raw)
In-Reply-To: <477BCB94.8060208@janestcapital.com>

Brian Hurt wrote:
> The OP did say "in place modification.
> 
Kuba also said "the output array is given as the argument, not as a
return value."

> It depends.  If you have to use multiple references to make the for-loop
> work, then I've seen tail recursion be faster (and clearer).  

Any example of a faster tail recursion?

> Also, if
> you recalculate the ending requirement every recursive call, recursion
> can be slower (in the above for loop above, for example, Array.length is
> gaurenteed to be called only once).

I have no problems precalculating the Array.length value, or recursing
down to 0.
> 
> Brian
> 

A little testing results in some data: for arrays of 1024 ints and
simple arithmetic operations, I get a 9% speed increase in using a for
loop over recursion.

E.


  reply	other threads:[~2008-01-02 19:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-02 16:52 Kuba Ober
2008-01-02 17:00 ` [Caml-list] " Jean-Christophe Filliâtre
2008-01-02 17:06   ` Brian Hurt
2008-01-02 17:26 ` Edgar Friendly
2008-01-02 17:36   ` Brian Hurt
2008-01-02 19:20     ` Edgar Friendly [this message]
2008-01-03 16:01       ` Kuba Ober

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=477BE419.8080400@gmail.com \
    --to=thelema314@gmail.com \
    --cc=bhurt@janestcapital.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=ober.14@osu.edu \
    /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