On 03.05.2010, at 20:30, David Mitchell wrote: > Bummed that Why Smalltalk is gone.
Yeah. It's still in the archive though: http://web.archive.org/web/*/whysmalltalk.com > Here is my crack at translating. Wouldn't say this is idiomatic Smalltalk > (transliterated C never will be). But it ran in the transcript. > > Tried to only use ANSI Smalltalk: > > | count doors | > count := 10. > "Initialize the array of doors to 0 (closed)" > doors := (Array new: count) atAllPut: false. > > "Process the doors" > 1 to: count do: > [ :pass | > pass to: count by: pass do: > [ :door | > doors > at: door > put: (doors at: door) not ] ]. > > "Print out the results" > 1 to: count do: > [ :n | > Transcript > show: 'door #', n, ' is '; > show: ((doors at: door) ifTrue: [#open] ifFalse: [#closed]); > cr] > This looks a lot like http://programming.dojo.net.nz/languages/smalltalk/index (although that code doesn't even run - could someone fix?) How about this one - demonstrates better what Squeak provides: | doors | doors := Array new: 100 withAll: false. 1 to: doors size do: [:pass | doors := doors collectWithIndex: [ :isOpen :door | (door isDivisibleBy: pass) xor: isOpen]]. ^ (1 to: doors size) select: [:door | doors at: door] - Bert -
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners