Exploring the APL One-Liner Solutions to Logiker’s Christmas Challenge on the Commodore 64
APL was used by three of the shortest entries in Logiker’s Christmas Challenge in 2023. Can these entries all be run on a Commodore 64 using APL/Z with its tiny 7174 byte workspace?
Start by running Vice x64sc, then press F12 to go to the Cartridge settings and enable the CP/M cart:
Drag and drop the CP/M disk into the emulator to load CP/M. After CP/M finishes loading, use F12 to set the Drive to use C64APLZ.d64. DIR will display the disk directory. Type APL to load in APL/Z80.
Enter the date in mmddyy format to begin working in a clear workspace.
Type control-tab to put the Commodore 64 into lower case mode. For details of APL/Z key equivalents and how to type the special APL characters see the notes.
Trying Dmsc’s entry first, we run into a problem right away. In APL/Z, the idiom usually used to print arrays, ‘ *’[1+array], seems to only work with vectors. Attempting to use it to print arrays causes a rank error:
A workaround is found using the ravel function (the comma) to squash the array into a vector, then performing a 19 by 19 reshape of the printable vector:
Next up, Logiker’s entry, using the same technique of reshaping the printable raveled vector:
Next up is paul7’s entry:
Bad news, APL/Z has a vector reverse but it lacks a matrix reverse. Fortunately, the documentation explains the situation and offers an implementation:
Implement the array matrix reversal function using the existing vector reversal primitive:
Try again, calling the new reversal function:
It looks like 7174 bytes is plenty of room to run each of these excellent APL submissions.
Many thanks to Logiker for hosting the wonderful Christmas Challenges!