kernelthread.com

WebL

The Towers of Hanoi as a WebL program.

According to the WebL web site:

Compaq's Web Language is a scripting language for automating tasks on the World-Wide Web. It is an imperative, interpreted language that has built-in support for common web protocols like HTTP and FTP, and popular data types like HTML and XML.

/* * The Towers Of Hanoi * WebL Implementation * Copyright (C) 2002 Amit Singh. All Rights Reserved. * http://hanoi.kernelthread.com * * Last tested under WebL3.0h + Java 1.4.1_02-b06 */ var MAXDISKS = 10; var H = fun(n, f, u, t) if n == 1 then PrintLn(f, " --> ", t) else H(n - 1, f, t, u); PrintLn(f, " --> ", t); H(n - 1, u, f, t) end end; var hanoi = fun(n) if (n > 0) and (n < (MAXDISKS + 1)) then H(n, 1, 2, 3) else PrintLn("usage: hanoi n, where 0 < n <= ", MAXDISKS) end end; hanoi(3);

Download

hanoi.webl