Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-28 Thread Lukasz Stafiniak
On Wed, Oct 28, 2009 at 5:52 PM, Xavier Leroy wrote: > Lukasz Stafiniak wrote: > >> While we are at it, what is the best way to convert a "straight" list >> into a cyclic list? > > Again, you can do that just fine using lazy lists instead of lists: > > type 'a lazylist = 'a lazylist_content Lazy.t

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-28 Thread Xavier Leroy
Mathias Kende wrote: > I need to write something like this : > > let f f i = if i = 0 then 1 else i * f (i - 1) > let rec g = f g > > Of course the compiler won't let me write it (even if the OCaml type > system is happy): > "This kind of expression is not allowed as right-hand

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-25 Thread Stéphane Glondu
Mathias Kende a écrit : > [...] I also want to write : > let rec h = t (f h) > (with t : ('a -> 'b) -> 'a -> 'b) but here, I can't afford to use > let rec h x = t (f h) x > because t as some side effects and I need it to be evaluated only once. Then what about: let h = let tmp = ref

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-25 Thread Mathias Kende
On Fri, 23 Oct 2009 00:34:29 +0200, Stéphane Glondu wrote: > Mathias Kende a écrit : >> let rec g = f g > > What about: > > let rec g x = f g x This will compile, but then I also want to write : let rec h = t (f h) (with t : ('a -> 'b) -> 'a -> 'b) but here, I can't afford to use

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-23 Thread blue storm
On Fri, Oct 23, 2009 at 6:14 PM, Marc de Falco wrote: > I don't know the exact rule, but I guess that on the right-hand side of a > let rec defining a ground value named foo you can only write a term which > evaluates to a finite ground term on the currently defined variables + foo. > That is to s

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-23 Thread Marc de Falco
message de : Lukasz Stafiniak du : 2009-10-23 01:10:37 À : caml-list CC : Sujet : Re: [Caml-list] forbidden construct as right hand side of "let rec" While we are at it, what is the best way to convert a "straight" list into a cyclic list? i.e. convert let l = a::b::[] i

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-23 Thread Damien Guichard
let list_cycle2 a b = let rec loop = a::b::loop in loop - damien En réponse au message de : Lukasz Stafiniak du : 2009-10-23 01:10:37 À : caml-list CC : Sujet : Re: [Caml-list] forbidden construct as right hand side of "let rec" While we are at it, what is the best way to

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-22 Thread Lukasz Stafiniak
While we are at it, what is the best way to convert a "straight" list into a cyclic list? i.e. convert let l = a::b::[] into let rec l = a::b::l (for arbitrary length lists). (The answer I recall from the archives was using Obj.magic to mutate the [] in the original list). On Fri, Oct 23, 200

Re: [Caml-list] forbidden construct as right hand side of "let rec"

2009-10-22 Thread Stéphane Glondu
Mathias Kende a écrit : > let rec g = f g What about: let rec g x = f g x -- Stéphane ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's lis

[Caml-list] forbidden construct as right hand side of "let rec"

2009-10-22 Thread Mathias Kende
Hello list, I need to write something like this : let f f i = if i = 0 then 1 else i * f (i - 1) let rec g = f g Of course the compiler won't let me write it (even if the OCaml type system is happy): "This kind of expression is not allowed as right-hand side of `let rec'"