"C˝┼ric Foll" <cedric.foll / bigfoot.com> writes:

> Hi,
> 
> i'm trying to code an 'option remember' in Ruby.
> This option should be used in order to save the result allready computed of
> a function.
> For exemple: fib=remember(:fib) transorm the fibonacci function in aO(n)
> function.
> I've tried a lot of things but nothing run, i've found nothing in the
> progmatic programmer and ruby in a nutshell books.

We discuss the 'once' trick on page 251, but that doesn't vary the
result depending on the parameter passed in. You could try extending
that, or you could have a look at Robert Feldt's memoize package:


   http://www.ce.chalmers.se/~feldt/ruby/extensions/memoize/


Cheers


Dave