Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
[NEWBIE] is there an in-place map?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Edgar Friendly <thelema314@g...>
Subject: Re: [Caml-list] [NEWBIE] is there an in-place map?
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.