kernelthread.com

PL/I

The Towers of Hanoi as a PL/I program.

*PROCESS langlvl(saa2) source; *PROCESS not('') or('|'); *PROCESS limits(extname(31)); hanoi:proc options(main); call dohanoi(3, 1, 3, 2); dohanoi:proc(n, f, t, u) recursive; dcl(n, f, t, u) fixed bin(31); if n > 1 then do; call dohanoi(n-1, f, u, t); call movedisk(f, t); call dohanoi(n-1, u, t, f); end; else call movedisk(f, t); end dohanoi; movedisk:proc(f, t); dcl (f, t) fixed bin(31); put skip list('move' || f, '->' || t); end movedisk; end hanoi;

Download

hanoi.pli