Tags

,

When I was a young lisper, of, say, 16 (which at the time was quite young, although these days would be considered quite old!), I read The Little Lisper (TLL). Of course, very few folks actually read TLL to learn Lisp; It’s mostly a curiosity among those who already know Lisp, or at least among quasi-adults trying to learn Lisp efficiently.

So usually, when one read TLL one usually actually just read through the whole book in one sitting, the whole exercise taking a whopping hour. When approached in this way, TLL seems a bit silly; After a couple pages, one says to oneself: “Oh come on! This is silly! Just give me a damned language manual!” (Indeed, I was one who said exactly these words, so I wrote my own!)

Now, however, I think that I — and pretty much everyone — was approaching TLL the wrong way. Obviously it’s not meant for those who know Lisp already. But I also don’t think that it’s meant for adults (or even quasi-adults) who want to learn Lisp efficiently. I contend that TLL is actually meant for CHILDREN (Soylent green is people!), or those of us who can put our mind in the mode of being a child, which I think is actually extremely difficult.

Brief aside: When you apply for at teaching job, they ask you to describe your “educational (or teaching) philosophy”. As one might expect, this is a difficult question, and I’m not going to try to give my whole teaching philosophy. But one of its pillars is this: You only get people’s (esp. children’s!) attention for a couple of minutes at a time, so be sure to do tiny fun things, and build them up over days, weeks, months, and years to reach where you want to go.

So when I decided that it was time for Leo to learn Lisp — specifically, when he turned 8, and was proficient at those “baby languages”, like scratch and hopscotch — I deployed my afore(partially)described teaching philosophy: I started with atoms, then lists, and so on, building up Lisp concepts and programming, no “lesson” consisting of more than about 10 minutes, and usually containing only one of a couple of concepts.

This worked exceptionally well with Leo (as you’ll see below). But just today, after a couple weeks at this, and now writing some actually vaguely-interesting programs, it just hit me that I was doing The Little Lisper ALMOST EXACTLY! Of course, wasn’t actually using TLL; rather, my teaching method enacted TLL! This is when the aforementioned realization that Soylent Green is… er… that TTL is written for children (or, again, more likely, adults with child-like minds — which probably describes Lispers of a certain age).

Okay, so this long winding dissertation is all by way of introducing Leo’s first substantial Lisp program, which we have called…

RANDOM-RAVEN

First we create two variables WORDS and PATTERNS:

(setf words '(
          Once upon a midnight dreary  while I pondered  weak and weary
          Over many a quaint and curious volume of forgotten lore
          While I nodded  nearly napping  suddenly there came a tapping
          As of some one gently rapping  rapping at my chamber door
          Tis some visitor  I muttered  tapping at my chamber door
          ...))

(setf patterns '(
          (Once upon a midnight dreary  while I pondered  weak and weary  )
          (Over many a quaint and curious volume of forgotten lore  )
          (    While I nodded  nearly napping  suddenly there came a tapping  )
          (As of some one gently rapping  rapping at my chamber door  )
          ( Tis some visitor  I muttered  tapping at my chamber door  )
          (            Only this and nothing more  )
          ()
          (    Ah  distinctly I remember it was in the bleak December  )
          (And each separate dying ember wrought its ghost upon the floor  )
          (    Eagerly I wished the morrow  vainly I had sought to borrow )
          (    From my books surcease of sorrow sorrow for the lost Lenore  )
          (For the rare and radiant maiden whom the angels name Lenore  )
          (            Nameless here for evermore  )
          ()
          (    And the silken  sad  uncertain rustling of each purple curtain )
          (Thrilled me filled me with fantastic terrors never felt before  )
          (    So that now  to still the beating of my heart  I stood repeating )
          (     Tis some visitor entreating entrance at my chamber door  )
          (Some late visitor entreating entrance at my chamber door   )
          (            This it is and nothing more  )
          ()
          ...))

(Yeah, yeah, we could have computed words from patterns…cut the 8 year old a break! He’s only been doing Lisp for about an hour total, over a couple weeks!)

Okay, so you can see where this is going:

(defun random-raven (w p)
  (loop for line in p
        do (print (loop for word in line
                        collect (nth (random (length w)) w)))))

Et voila!

(MANY THIS WORD THING HORROR OF ITS ER ME MAIDEN LENORE)
(MORE NIGHT IS OF RELEVANCY SAD CHAMBER IS TOKEN WORD)
(NEVERMORE AS LENORE BUT I NEVERMORE ANSWER WHEN VOLUME YOUR)
(ENCHANTED TUFTED NOTHING WITH SAID AND DOUBTING SURE MORE SILENCE BURNED)
(JUST BE AT SO EYES NOTHING DECORUM A BEFORE MY)
(WAS THY A NEVERMORE IF)
NIL
(TAKE BEFORE SURELY BACK NEVERMORE US HATH SOUL LORE BUT)
(OF JUST ONE THAT TIS I WITH A FOLLOWED WHEELED THE)
(LENORE PERCHED RAPPING OF CORE THE VELVET FOWL PERCHED MARVELLED WHISPERED)
(THEN THE AND THEREAT NEVERMORE NOTHING RADIANT FLOOR UNCERTAIN DEVIL I)
(SO WAS A RECLINING WAS MY SEE SINKING AND NOW OF)
(LET BUT AND LENORE)
NIL
(YET MYSELF SMILING THOU PALLAS YORE BIRD MY OH ANCIENT)
(MORROW TELL HEART DECEMBER RAVEN O THIS VELVET DIVINING OF)
(FOR STILL I MIDNIGHT STILL HAUNTED SOME THAT TAPPING THE STILL NAME BETOOK)
(CUSHIONED PALLID OBEISANCE EAGERLY I ITS I SYLLABLE DOOR)
(SAT AND THAN BIRD THE WITH FRONT TUFTED UNCERTAIN)
(FLUNG MY ONE EVIL SUDDENLY HUMAN)
...

And so on! If read with the correct Vincent Price horror movie voice and prosodics, this stuff sounds both great and hysterically funny!

Next week… Eliza?! 🙂