Racket Slideshow Poems

Last week's talk about a local poet reminded me of I.A. Richards. I read that he used to put a poem on a slide up before large groups of people. William Empson may have written a poem about the slides.

Yeats King and No King slide

I like the simple slides, maybe I'll use them to contemplate poetry while staring at a screen. On the other hand commercial presentation software ( PP ) seems too flashy.

Yeats The Witch Slide

The loud colors distract from contemplation on the poem. If putting poems up on a screen can be constructive, a simple way to see simple slides may be useful.

Using DrRacket to show poems in the tradition of I.A. Richards seems appropriate. As learners of poetry and programming we want grounds to approach an “overwhelming sense of correctness” (fn:1) ... to reach a judgment that we can have confidence with.

DrRacket Slideshow for Poems

It felt good to discover that basic ideas about recursion with simple lists from The Little Schemer could be used with picts in Racket's slideshow language. Instead of the empty list '() and cons : (blank 0) and vl-append ....

code

#lang slideshow

(define poem-files-for-slides
  "Yeats-MaidQuiet.txt Yeats-SternerConscience.txt Yeats-KingAndNoKing.txt Yeats-ACoat.txt Yeats-TheWitch.txt Yeats-TheSecondComing.txt Yeats-TheSecondComing.txt Yeats-TheseAreTheClouds.txt Yeats-WellAndTree.txt Yeats-WorkToNothing.txt")
(define poem-files-list (string-split poem-files-for-slides))
; (define poem-lines (string-split poem-str "\n"))
(define (str->path str)
  (build-path (current-directory-for-user) str))

(define (get-poem-lines str)
  (define inp (open-input-file (str->path str)))
  (define lines (port->lines inp))
  (close-input-port inp)
  lines)

(define line-text-size 30)
(define title-text-size (* 1.2 line-text-size))
(define poem-style 'roman)
  ;;alternate style (cons 'italic 'roman))

(define (string-empty? str)
  (if (non-empty-string? str)
     #f
     #t))

(define (end-with-space line)
  (if (string-empty? line)
     ""
     (string-append line " ")))

(define (poem-line->pict-text line)
  (text
   (end-with-space line)
       poem-style line-text-size))

(define (poem->pict lines)
  (define title (first lines))
  (define poem (cdr lines))
  (define (helper lines keep)
    (cond
      ((empty? lines) keep)
      ((string-empty? (car lines))
       (helper (cdr lines) (vl-append keep (car lines))))
      (#t (helper (cdr lines)
                 (vl-append keep (car lines))))))
  (vl-append
   (text title poem-style title-text-size)
   (helper
    (map poem-line->pict-text poem) (blank 0))))

(define (poem-slide pict)
  (slide #:layout 'top
        pict))

(define (file-str->poem-slide str)
  (define poem-lines (get-poem-lines str))
  (poem-slide      
   (poem->pict (map end-with-space poem-lines))))

(map file-str->poem-slide poem-files-list)

Poems from:

#slideshow #DrRacket #Racket #Pict #poetry #poem #Yeats #WEBYeats #FreeSoftware #IaR #IaRichards