From: Brian H. <bh...@sp...> - 2005-08-10 01:11:17
|
On Wed, 10 Aug 2005, skaller wrote: > On Tue, 2005-08-09 at 19:46 -0500, Brian Hurt wrote: >> >> I don't think we need an exception to do this. Wouldn't this do: >> >> let fold_left_while f p init lst = >> let rec loop accu = function >> | h :: t -> >> if p h then loop (f accu h) t else accu >> | [] -> accu >> in >> loop init lst >> ;; > > Yes, that's good! Having gone back and read the first message in this thread- the only difference between my code and the original proposed code is: 1) I shortened some of the variable names (note that this is not necessarily good) 2) I created an inner loop function, instead of making fold_left_while recursive. Otherwise, my code is identical to the code originally posted. Brian |