Browse thread
Avoiding shared data
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-10-01 (18:02) |
From: | Wolfgang Lux <wlux@u...> |
Subject: | Re: Ant: Re: [Caml-list] Avoiding shared data |
Wolfgang Lux wrote: > let myfunc l = > let g y result = > if ypred y then > let z = verbose_code_using_y y in z_expression :: result > else > result > in let f x result = > if xpred x then > let y = verbose_code_using_x x in g y result > else > result > in fold_right f l [] Just correcting myself. The code should use fold_left rather than fold_right (and thus switch the parameters in the call as well as that of the local functions f and g) because the former is tail recursive and therefore should be preferred in a strict language (have been programming too much Haskell lately where a right fold is better). Wolfghang