[Newbies] assorted beginner questions

Blake blake at kingdomrpg.com
Wed Oct 3 05:21:16 UTC 2007

On Tue, 02 Oct 2007 20:22:01 -0700, Mark Smithfield  
<m_smithfield at yahoo.com> wrote:

> In the floor method from Number,
>     truncation _ self truncated.
> What does the underscore mean?


In some images it shows up as a left-pointing arrow.

I'm not sure if that's coming back in later iterations or not.

> 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.)

More information about the Beginners mailing list