creating new ones of your own design or adding to existing classes.
If want an idea: try a simple LISP subset, using Ruby’s lists as the
underlying data structure.
Lists are class Array, so you could do
class Array
def car()
self[0]
end
# etc
end
which will allow you to write “[2, 4, 5].car”
Ruby:
Implement car, cdr, cons (cons is probably just a stand-alone function).
How about some of the utility functions: length; assoc (with an
argument like [[:top, 24], [:bottom, 12]] )
2. This simple Hanoi has a problem: it tells you all the moves, but
not what’s on each pole as we move through the game. Here’s an example
from a solution which I did in Java last year. Can you do as well in
Io? Shouldn’t be too hard, given that it has “push” and “pop” builtins.
% java Hanoi 3
At beginning: A[3, 2, 1]
B[] C[]
Task: move 3 from A[3, 2, 1] to B[]
first clear 2 from A[3, 2, 1] to C[]
Task: move 2 from A[3, 2, 1] to C[]
first clear 1 from A[3, 2, 1] to B[]
Move: #1 from A to B A[3, 2]
B[1] C[]
done clearing 1 from A[3, 2] to B[1]
Move: #2 from A to C A[3] B[1] C[2]
unclear 1 from B[1] to C[2]
Move: #1 from B to C A[3] B[]
C[2, 1]
done moving 2 from A[3] to C[2, 1]
done clearing 2 from A[3] to C[2, 1]
Move: #3 from A to B A[] B[3]
C[2, 1]
unclear 2 from C[2, 1] to B[3]
Task: move 2 from C[2, 1] to B[3]
first clear 1 from C[2, 1] to A[]
Move: #1 from C to A A[1] B[3] C[2]
done clearing 1 from C[2] to A[1]
Move: #2 from C to B A[1] B[3,
2] C[]
unclear 1 from A[1] to B[3, 2]
Move: #1 from A to B A[] B[3, 2,
1] C[]
done moving 2 from C[] to B[3, 2, 1]
done moving 3 from A[] to B[3, 2, 1]
All finished: A[] B[3, 2,
1] C[]
done, 7 moves for 3 disks





