Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: recursive definition
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: e@f...
Subject: Re: recursive definition

>let rec fib = remember(fun x ->
>  if x < 2 then 1 else fib(x-1) + fib(x-2)
>);;
>EntrHe interactive:
>>..............remember(fun x ->
>>  if x < 2 then 1 else fib(x-1) + fib(x-2)
>>).......
>Ce genre d'expressions n'est pas autorisH comme membre droit d'un "let
>rec".

How about:

#let rec fib x = remember(fun x ->
  if x < 2 then 1 else fib(x-1) + fib(x-2)
) x ;;

e