kernelthread.com

Sather

The Towers of Hanoi implemented in Sather.

Quoted from the Sather home page:

Sather is an object oriented language designed to be simple, efficient, safe, flexible and non-proprietary. One way of placing it in the "space of languages" is to say that it aims to be:

Sather has garbage collection, statically-checked strong typing, multiple inheritance, separate implementation and type inheritance, parameterized classes, dynamic dispatch, iteration abstraction, higher-order routines and iters, exception handling, assertions, preconditions, post-conditions, and class invariants. Sather code can be compiled into C code and can efficiently link with C object files.

-- -- The Towers Of Hanoi -- Sather -- Copyright (C) 2001 Amit Singh. All Rights Reserved. -- http://hanoi.kernelthread.com -- class MAIN is movedisk(f, t : STR) is #OUT + f + " --> " + t + "\n"; end; dohanoi(n: CARD, f, t, u: STR) is if n < 1 then return; else dohanoi(n - 1, f, u, t); movedisk(f, t); dohanoi(n - 1, u, t, f); end end; hanoi(n : CARD) is dohanoi(n, "1", "3", "2"); end; main is hanoi(3); end; end;

Download

hanoi.sa