Will You Play APL With Me?
summary
Builds a working text-justifier in APL that turns left-wrapped lines into right-aligned paragraphs by converting the text to a character matrix, identifying trailing spaces with a boolean mask, computing trailing counts with scan/reduce, dividing and flooring to get per-gap allocations and distributing remainders by enumerating gaps. Demonstrates right-to-left evaluation, the rank operator to map row-wise operations, and using the replicate function to expand characters, then runs the same code on a 12,486-line Gutenberg file to show it completes almost instantly and recovers from a live RANK ERROR.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:20Building blocks of APL: functions and operators
- 3:42Right to left syntax
- 5:00Justifying text problem
- 6:58Defining a character matrix variable
- 11:13Mask of trailing spaces
- 15:18Positions and amounts of spaces to insert
- 28:25Replicating spaces in text
- 30:40Processing a large corpus from file
- 34:05What does masking with Booleans mean?
- 37:55Using the rank operator
- 39:10When not to justify text
- 40:08RANK ERROR
- 41:50Sharing code for others
- 42:45Multiply vs compress for masking values
