Cool. I&#39;ve just understood the 100 doors problem looking at your code. I was too lazy to try to understand the original one on <meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://programming.dojo.net.nz/languages/smalltalk/index">http://programming.dojo.net.nz/languages/smalltalk/index</a> :)<div>

<br clear="all">Laurent Laffont<br>
<br><br><div class="gmail_quote">On Tue, May 4, 2010 at 5:55 PM, John McKeon <span dir="ltr">&lt;<a href="mailto:p3anoman@gmail.com">p3anoman@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Looking at <a href="http://rosettacode.org/wiki/100_doors" target="_blank">rosettacode</a> most languages look nearly identical 
(or, at the very least, ugly/crappy) when written out procedurely so 
that one might end up deciding to just stick with C.<br><br>I know I am 
going off the deep end a bit, but the whole answer to &quot;why Smalltalk?&quot; 
lies in the fact that problems should/would be approached in a 
completely different manner. As I am sure they would in most of the 
other languages if one were not restricted to 20 or so lines of code.<br>
<br>Since it is example code, at least in the case of Smalltalk, an 
object oriented solution would be in order - i.e. show how it would be 
solved using &quot;everything is an object&quot;. Unfortunately, it doesn&#39;t really
 fit into &quot;a few lines of code&quot; to display on a page (even though the 
classes/objects and code required to implement them is little more than a
 few lines). And you also don&#39;t get any feel for the great tools. 
Perhaps, some insight into how one would run the code in Java/Eclipse, 
or Visual C &lt;chuckle&gt; with all the includes and project setup, etc
 might be a useful addition to the comparisons...<br>
<br>Object subclass: #Corridor<br>    instanceVariableNames: &#39;doors 
count&#39;<br>    classVariableNames: &#39;&#39;<br>    poolDictionaries: &#39;&#39;<br>    
category: &#39;100Doors&#39;<br><br>initialize: anInteger<br>
    &quot;initialize the receiver with the given number of doors&quot;<br>    
count := anInteger.<br>    doors := OrderedCollection new.<br>    
anInteger timesRepeat: [ doors add: Door new ]<br><br>pass<br>    
&quot;iterate over the doors&quot;<br>
    1 to: count do: [ :i | self passBy: i ]<br><br>passBy: anInteger<br>   
 &quot;if the nth door is open close it otherwise open it&quot;<br>    doors by: 
anInteger do: [ :door | door toggle ]<br><br>printOn: aStream<br>
    &quot;print  the open doors&quot;<br>    aStream cr.<br>    doors withIndexDo:
 [ :door :i | door isOpen ifTrue: [ aStream nextPutAll: i asString, &#39; is
 open&#39;; cr ]]<br><br>Corridor class<br><br>pass: anInteger<br>
    &quot;return a new Corridor with the given number of doors that has been 
passed thru&quot;<br>    ^self new <br>        initialize: anInteger; <br>   
     pass<br><br><br>==================================================================<br>
<br>Object subclass: #Door<br>    instanceVariableNames: &#39;isOpen&#39;<br>   
 classVariableNames: &#39;&#39;<br>    poolDictionaries: &#39;&#39;<br>    category: 
&#39;100Doors&#39;<br><br>isOpen<br>    &quot;Answer the value of isOpen&quot;<br>
    ^ isOpen<br><br>toggle<br>    &quot;if the receiver is open close it else
 open it&quot;<br>    isOpen := isOpen not<br><br>initialize<br>    
&quot;initialize the receiver to be closed&quot;<br>    super initialize.<br>
    isOpen := false<br><br>===========================================================<br>Patch
 to iterate over a collection by each nth item<br>
<br>OrderedCollection&gt;&gt;by: anInteger do: aBlock<br>    | index |<br>
    index := anInteger.<br>    [index &lt;= lastIndex]<br>        
whileTrue: <br>            [aBlock value: (array at: index).<br>        
    index := index + anInteger]<br><br><br>Probably silly for the 
problem given but just my 2 cents<br>John<br><font color="#888888"><br clear="all"><br>-- <br><a href="http://john-mckeon.us/seaside" target="_blank">http://john-mckeon.us/seaside</a><br>
</font><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>