Version française
Home     About     Download     Resources     Contact us    
Browse thread
More problems with memoization
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin1977@l...>
Subject: Re: [Caml-list] More problems with memoization
On Sun, 1 Oct 2006, Jon Harrop wrote:

> I believe you want to "untie the knot" of recursion, creating an higher-order,
> auxiliary fibonacci function fib_aux that accepts the recursive call as an
> argument:
>
> # let rec fib_aux fib = function
>    | 0 | 1 as n -> n
>    | n -> fib(n - 1) + fib(n - 2);;
> val fib_aux : (int -> int) -> int -> int = <fun>

Since the point is to make the function not recursive, I think you 
shouldn't use "let rec" :-)


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr