[squeak-dev] Rosetta Code site
Andres Valloud
avalloud at smalltalk.comcastbiz.net
Sun May 3 20:46:33 UTC 2009
Hey, this is great material for the book I am writing. Thank you!
Daniel Ingalls wrote:
> Hi all -
>
> Today while looking for an old reference to Rosetta Smalltalk, I came
> across this site:
>
> http://rosettacode.org
>
> In their own words, "The idea is to present solutions to the same task
> in as many different languages as possible, to demonstrate how
> languages are similar and different, and to aid a person with a
> grounding in one language in learning another. Rosetta Code currently
> has 278 tasks, and covers 135 languages, though we do not have
> solutions to every task in every language."
>
> It seemed to me that some of the Smalltalk examples are not as nice as
> they might be. For instance the very first thing I looked at was the
> Ackermann function which is written as a block...
>
> |ackermann|
> ackermann := [ :n :m |
> (n = 0) ifTrue: [ (m + 1) ]
> ifFalse: [
> (m = 0) ifTrue: [ ackermann value: (n-1) value: 1 ]
> ifFalse: [
> ackermann value: (n-1)
> value: ( ackermann value: n
> value: (m-1) )
> ]
> ]
> ].
>
> To begin with, this is cluttered with value:value:; it includes
> redundant parentheses which don't belong in an illustration of the
> language; finally, it will not run in Smalltalks that do not allow
> recursive blocks. Seems to me it might be more illustrative as an
> Integer method that will run in any Smalltalk, that runs faster too,
> and looks cleaner to me...
>
> <Integer> ack: n "The first parameter m is the receiver, self, in
> this Ackermann method"
> self = 0 ifTrue: [^ n+1].
> self > 0 ifTrue:
> [n = 0 ifTrue: [^ self-1 ack: 1].
> n > 0 ifTrue: [^ self-1 ack: (self ack: n-1)] ]
> "
> 0 ack: 0 ==> 1
> 3 ack: 4 ==> 125
> "
>
> Anyway, I thought Smalltalk's representation on that site could use a
> little QA, and that folks on this list might have a good time playing
> TerseMan. I could imagine the Squeak solutions being an interesting
> area in our Wiki, both as a staging area for such a project, and as a
> possibly interesting collection of TerseMan discussions (terseness is
> great fun, but not always the ideal). A comment on the last line
> might point to our Wiki which might gain some new Squeak users, and
> would encourage checking with us before anyone overwrites our
> contributions.
More information about the Squeak-dev
mailing list
|