a scheme program

Thursday August 03, 2006
some jerk is not learning about functional programming

(define (parse callback)
(lambda (data)
(if (>= (string-length data) 10)
((parse (callback (substring data 0 10))) (substring data 10))
(lambda (moredata)
((parse callback) (string-append data moredata))))))

(define (make-line-writer n)
(lambda (line)
(display (format "~A: '~A'\n" n line))
(make-line-writer (+ n 1))))

((((((parse (make-line-writer 1))
"hello") " world") " radix") " is") " dumb!!!!!!!!!!!!!!!")

Update: In addition to not being buggy, I've changed it so that this version is actually functional as well.
Update 2: Forgot the formatting change in the last update.