logo       

Re: Beginners Digest, Vol 18, Issue 2: msg#00002

lang.smalltalk.squeak.beginners

Subject: Re: Beginners Digest, Vol 18, Issue 2

> > I want to apply smalltalk to fibonacci numbers. I
> add
> > this method
> > to Integer,
> >
> > fib:
> > (self = 0) ifTrue: (^0)
> > (self = 1) ifTrue: (^1)
> > ^ (self - 1 fib) + (self - 2 fib).
> >
> > Next, I would like to memoize this method,
> (because of
> > the enormous performance gains). I do not see how
> to
> > memo-ize things in smalltalk. Can somebody help me
> see the necessary
> > shift in thinking?
>
> I don't see why memoization would be different in
> Smalltalk. Or why it
> would specifically have to be, rather. You might
> create a Fibonacci class
> that contained an array or somesuch and cached the
> numbers that had
> already been called. (Slowly taking up more and more
> space over time.)

So. You would have an array called Fibs or Primes, and
just stack up a collection of Primes that would hang
around?

I think that I would enjoy that. I think I get it.

(Thanks I think)
or
Thanks I: think.




____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the
tools to get online.
http://smallbusiness.yahoo.com/webhosting


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise