Version franaise
Home About Download Resources Contact us
Browse thread
The Implicit Accumulator: a design pattern using optional arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thomas Fischbacher <tf@f...>
Subject: Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments
Jon Harrop wrote:

> I would write:
> 
>   let rec work sum = function
>     | 0 -> sum
>     | todo -> work (sum + todo) (todo - 1)
> 
>   let sum_nums n = work 0 n
> 
> because it is shorter, clearer, 65% faster and it is idiomatic ML rather than 
> idiomatic Lisp.

You are still evading the issue: you nevertheless pass multiple
arguments to a continuation, rather than consing a return value.

But apart from this: I find it somehow strange that the OCaml compiler
produces noticeable differences in the speed of compiled code when one
does some transcriptions that actually should not matter, such as when
replacing for with Array.iter...

-- 
best regards,
Thomas Fischbacher
tf@functionality.de