Version française
Home     About     Download     Resources     Contact us    
Browse thread
The need to specify 'rec' in a recursive function defintion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Saptarshi Guha <saptarshi.guha@g...>
Subject: Re: [Caml-list] The need to specify 'rec' in a recursive function defintion
Thanks, very helpful.

>> let f = fun x -> x + 1   (1)
>>
>> let f x = f (f x)  (2)

This works in ocaml because, it replaces f (in (2) ) from that of (1).
Which is why i need f previously defined.
Correct me if i'm wrong.


>
>> Wouldn't one of way of detecting a recursive function would be to see
>> if the indeed the function calls itself?
>
> No. Because you never know if you intended to call the function recursively,
> or if you intended to call an homonymous function you defined before.
>

Very true, hadn't considered this.


> All the best,
>
> --
>     Guillaume Yziquel
> http://yziquel.homelinux.org/
>