Archive for February, 2007

Smalltalk snippet of the day: Fizz Buzz

Wednesday, February 28th, 2007

The spec. is: print the numbers from 1 to 100, except where a number is divisible by 5, print “Fizz”, and where divisible by 7, print “Buzz”. Where divisible by both, print “Fizz Buzz”.

1 to: 100 do:
[ :i | | fb |
fb := (#((5 'Fizz') (7 'Buzz'))
[...]

Smalltalk example of the day

Friday, February 23rd, 2007

I often find myself typing out code snippets to prove to myself that, yes, it really is easy in Smalltalk. Rather than keep them to myself, I think they may be useful as examples of Smalltalk code, so I’m going to try starting a series.
At The Daily WTF, they are removing spaces from a string. [...]