Friday, March 30, 2007


I felt a little silly today, and just learned about SRFI 42 (Eager Comprehensions), so I thought I might play with it on a trivial example.

(module happy-birthday-song mzscheme
(require (lib "")
(lib "" "srfi"))

(provide sing)

;; sing: string -> void
;; Prints out the popular happy birthday stanza.
(define (sing person)
(local ((define (trailer i)
(cond [(= i 2)
(format "dear ~a" person)]
"to you"])))
(do-ec (: i 4)
(display "Happy birthday ")
(display (trailer i))

No comments: