kernelthread.com

Smalltalk

The Towers of Hanoi implemented in Smalltalk.

"The Towers of Hanoi Smalltalk Copyright (C) 2004 Amit Singh. All Rights Reserved. Tested under Squeak on Mac OS X" moveDisk: fromTower to: toTower Transcript cr. Transcript show: (fromTower printString, '-->', toTower printString). doHanoi: n from: fromTower using: usingTower to: toTower (n > 0) ifTrue: [ self doHanoi: (n - 1) from: fromTower using: toTower to: usingTower. self moveDisk: fromTower to: toTower. self doHanoi: (n - 1) from: usingTower using: fromTower to: toTower] (Object new) doHanoi: 3 from: 1 using: 2 to: 3.

Download

hanoi.st