diff --git a/README.adoc b/README.adoc index 5a8f726151f89496cc524cbb5c6d2b6d286812b6..c9bfc3ecc5619911a62742ef9a6080690f056960 100644 --- a/README.adoc +++ b/README.adoc @@ -53,7 +53,7 @@ C# 5 33 1 229 TypeScript 5 28 6 216 Lua 5 28 6 215 -Smalltalk 5 41 0 208 +Smalltalk 5 37 0 207 Swift 5 33 29 204 Ruby 5 28 1 192 Kotlin 5 26 1 186 diff --git a/Smalltalk/cell.st b/Smalltalk/cell.st index c55b8e54a2246e0dd28217f83aac4a766e93005b..b5e5d07d7292fbc377e1a46cdf7a5dfbfcd1fb36 100644 --- a/Smalltalk/cell.st +++ b/Smalltalk/cell.st @@ -16,11 +16,8 @@ Object subclass: Cell [ printOn: stream [ state ifTrue: [ ' x |' displayOn: stream ] - ifFalse: [ ' |' displayOn: stream ] ] -] + ifFalse: [ ' |' displayOn: stream ] ] ] Cell class extend [ alive [ ^aliveValue ] - dead [ ^deadValue ] -] - + dead [ ^deadValue ] ] diff --git a/Smalltalk/coord.st b/Smalltalk/coord.st index 9990d76835efcd5fc87fcc6bb6d8d04ec0ab3b0c..bdf453018158bedc9b399da28b17b3694464f4ab 100644 --- a/Smalltalk/coord.st +++ b/Smalltalk/coord.st @@ -23,6 +23,4 @@ Object subclass: Coord [ = arg [ ^ x = arg x and: [ y = arg y ] ] - hash [ ^ (self displayString hash) ] -] - + hash [ ^ self displayString hash ] ] diff --git a/Smalltalk/main.st b/Smalltalk/main.st index 3c6a45c2f37806884a441ef48796225b6a06fd15..04cd4396a568ce616a13bb180c1aa051bd05e0d7 100755 --- a/Smalltalk/main.st +++ b/Smalltalk/main.st @@ -18,7 +18,7 @@ Object subclass: Conway [ world := World newWithSize:30 aliveCells:cells. generation := 0. [ - Conway clrscr. + Conway clearScreen. generation := generation + 1. world printNl. 'Generation ' display. @@ -27,10 +27,9 @@ Object subclass: Conway [ world := world evolve. ] repeat ] - Conway class >> clrscr [ + Conway class >> clearScreen [ ('%1[2J' % #($<16r1B>)) displayNl. ('%1[H' % #($<16r1B>)) displayNl ] ] Conway main. - diff --git a/Smalltalk/tests.st b/Smalltalk/tests.st index 9935a9d7c01c5c38bb23905c3ead4acfdf8f6108..ebcf0e3d63dcfa873e468857563f8bf32fb99f72 100755 --- a/Smalltalk/tests.st +++ b/Smalltalk/tests.st @@ -7,6 +7,7 @@ FileStream fileIn: 'world.st'. TestCase subclass: ConwayTests [ testBlock [ | alive original next | + 'testBlock' displayNl. alive := World block:(Coord newWithX:0 y:0). original := World newWithSize:5 aliveCells:alive. next := original evolve. @@ -14,6 +15,7 @@ TestCase subclass: ConwayTests [ testTub [ | alive original next | + 'testTub' displayNl. alive := World tub:(Coord newWithX:0 y:0). original := World newWithSize:5 aliveCells:alive. next := original evolve. @@ -21,6 +23,7 @@ TestCase subclass: ConwayTests [ testBlinker [ | alive original gen1 gen2 expectedAlive expected | + 'testBlinker' displayNl. alive := World blinker:(Coord newWithX:0 y:1). original := World newWithSize:3 aliveCells:alive. gen1 := original evolve. @@ -34,4 +37,3 @@ TestCase subclass: ConwayTests [ self assert: original = gen2 ] ] ConwayTests suite run. - diff --git a/Smalltalk/world.st b/Smalltalk/world.st index 9692c374449ee670d4f69fd90f0d7b9b97017230..0c2900ffe009f6d5e53ed6a9edbbefcce2722501 100644 --- a/Smalltalk/world.st +++ b/Smalltalk/world.st @@ -40,8 +40,7 @@ Object subclass: World [ cell = Cell alive ifTrue: [ (count = 2 or: [ count = 3 ]) ifTrue: [ alive add: coord ] ]. cell = Cell dead ifTrue: [ count = 3 ifTrue: [ alive add: coord ] ] ]. - ^ World newWithSize: size aliveCells: alive. - ] + ^ World newWithSize: size aliveCells: alive ] printOn: stream [ | interval |