English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] recursive or loop
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-03-08 (07:52)
From: Michael Wohlwend <micha-1@f...>
Subject: Re: [Caml-list] recursive or loop
On Tuesday 07 March 2006 17:02, Alan Falloon wrote:
> Converting a recursive function to a tail-recursive one is as hard as
> converting it to an interative algorithm: the two forms are pretty much
> the same.

I have indeed some problems converting it to a loop or to a tail-recusrsive 
function. It's of the form:

let rec search result =
	if some_test then record_the result
	else begin
		iter (fun element ->
			iter (fun ...);
			search (element :: result); (* !!! *)
			iter (fun ...);
		) data
	end
;;	

so the recursive call is in the middle and in an List.iter statment :-(

cheers
 Michael