Exploring the APL One-Liner Solutions to Logiker’s Christmas Challenge on the Commodore 64

solarbreeze
3 min readJan 4, 2024

--

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?

Tied for #1 is pdw with a J solution

Start by running Vice x64sc, then press F12 to go to the Cartridge settings and enable the CP/M cart:

With the CP/M cart enabled we can run APL.COM on a CP/M disk

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.

Using CP/M allows you to run vintage APL/Z on the C64

Enter the date in mmddyy format to begin working in a clear workspace.

APL/Z on the Commodore 64

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:

Dmsc’s entry runs into a problem with the ‘*’[1+array] idiom

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:

Instead use a 19 19 Reshape of Ravelled [1+,array]

Next up, Logiker’s entry, using the same technique of reshaping the printable raveled vector:

A thing of beauty is a joy forever

Next up is paul7’s entry:

rank error

Bad news, APL/Z has a vector reverse but it lacks a matrix reverse. Fortunately, the documentation explains the situation and offers an implementation:

The APL/Z documentation provides a solution to the missing primitive

Implement the array matrix reversal function using the existing vector reversal primitive:

Roll your own matrix reversal

Try again, calling the new reversal function:

The ! character is APL/Z’s representation of the logical Or V glyph

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!

--

--

solarbreeze
solarbreeze

Written by solarbreeze

6502 and APL enthusiast ♢ UFO analyst ♢ mudlark

No responses yet