Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Applications written in O'Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] Simple question
Maxence Guesdon <maxence.guesdon@inria.fr> writes:

> You want your accum to be a 'a list, not 'a, so use it as a list :
> 
> let rec apply_fun_list x f_list accum =
>   match f_list with
>      h::t ->
>            apply_fun_list x t (accum@(h x))
>    | [] ->
>         accum;;

erg, apply_fun_list become tail recursive, but it's in O(n^2) (when
the first version is in O(n)), and as @ is not tail recursive, this
doesn't resolve the problem of Usage of the stack....

better stick to the non tail recursive version that to do this.

-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners