|
Re: Beginners Digest, Vol 18, Issue 2: msg#00002lang.smalltalk.squeak.beginners
> > 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> |
|---|---|---|
| Previous by Date: | Re: assorted beginner questions, Blake |
|---|---|
| Next by Date: | RE: assorted beginner questions, Ron Teitelbaum |
| Previous by Thread: | assorted beginner questions, Mark Smithfield |
| Next by Thread: | Re: Re: Beginners Digest, Vol 18, Issue 2, Michael Davies |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |