A+ (an APL)

The Towers of Hanoi as an A+ program. A+ is an APL dialect available under the GNU Public License for a variety of platforms.

According to the A+ web site (quoted verbatim):

A+ is a descendent of the language "A" created in 1988 by Arthur Whitney at Morgan Stanley. At the time, various departments had a significant investment in APL applications and talent, APL being a language well-suited to the manipulation of large arrays of numbers. As technology was moving from the mainframe to distributed systems, there was a search for a suitable APL implementation to run on SunOS, the distributed platform of the period. Not happy with the systems evaluated, Arthur, motivated by management, wrote one geared to the business: large capacity, high performance. He was joined in his efforts as the language took on graphics, systems' interfaces, utility support, and an ever-widening user community. Over the course of the next few years, as the business began to reap tangible value from the efforts, the pieces were shaped into a consistent whole and became A+. The "+" referred to the electric graphical user interface. An A+ development group was formally created in 1992. A+ soon became the language of choice for development of Fixed Income applications. It offered familiarity to the APL programmers, the advantages of an interpreter in a fast-paced development arena and admirable floating point performance. A significant driver was that many of Morgan Stanley's best and brightest were the developers and supporters of the language. Through their practical application of technical values, they instilled fervent enthusiasm in talented programmers, regardless of their programming language backgrounds.

$mode ascii // The Towers Of Hanoi // A+ Implementation // Copyright (C) 2002 Amit Singh. All Rights Reserved. // // // Tested under aplus-fsf-4.18 // // // For very obvious reasons, ASCII equivalents to APL graphics have // been used (as enabled by the "$mode ascii" line above). You can // try the following APL sequence to look at the APL<->ASCII mapping // on your implementation: // // _nl{`;`ascii} // move{f; t}: { sys.write{1; f; 1}; sys.write{1; " --> "; 5}; sys.write{1; t; 1}; sys.write{1; "\n"; 1}; } // Recursive // dohanoi{n; f; u; t}: { if (n <= 1) move{f; t} else { dohanoi{n - 1; f; t; u}; move{f; t}; dohanoi{n - 1; u; f; t}; } } // Harness function // hanoi{n}: { if (n < 1) drop "illegal number of disks (must be between 1 and 10)\n" else if (n > 10) drop "illegal number of disks (must be between 1 and 10)\n" else dohanoi{n; '1'; '2'; '3'} }