But what does literature have to do with programming? What does the essential distillation of truth and perception have in common with a bunch of instructions for a computer?
The Bard gets a little wordy, but we wouldn’t have it any other way. Several clever devices are employed—for example, the use of Math.max ensures that theResult does not suffer the indignity of being addressed by a negative index.
Borges’s solution combines several of his favorite motifs: mathematical theory, the geometric arrangement of spaces, a suggestion of infinity, and a story within a story. This is classic Borges: a narrator—who, in his excitement, possibly overplays the staircase imagery—tells of a mysterious book (Monsters Ascending a Staircase), and within a few short lines, we’re right there living it.
As we watch the dogged procession of upwardly mobile monsters, we can’t help wondering when Borges will get to the math part. Predictably, it turns out we were already there; the rank of the stair represents the numerator, and each monster’s stride the denominator. Stairs that remain unstomped have no divisors and are thus primes. By transporting us to this imaginary world, Borges creates a distraction from the raw mechanics of prime numbers, while simultaneously illustrating how utterly simple, and universal, they are.
Sometimes the assignment proved to be too much, and the author would abandon it and instead send me a poem documenting the dark depths of their coding despair.
Here’s Edgar Allan Poe’s reworking of The Raven:
Once upon a midnight dreary, while I struggled with JQuery,
Sighing softly, weak and weary, troubled by my daunting chore,
While I grappled with weak mapping, suddenly a function wrapping
Formed a closure, gently trapping objects that had gone before.
Ah, distinctly I remember, it was while debugging Ember,
As each separate dying member left its host for evermore.
Eagerly I wished the morrow—vainly I had sought to borrow
(From my bookmarked trail of sorrow), APIs from Underscore.
There I sat engaged in guessing the meaning of each cursed expression,
Endless callbacks in procession; nameless functions, nothing more,
This and more I sat divining, strength and spirit fast declining,
Disclose the value we’re assigning! Tell me—tell me, I implore!