#3: Friendlier `letrec`

Tagged as challenge

Written on 2018-01-30

Write with-definitions, a version of letrec which allows one to use define-like syntax in Scheme. For instance, I should be able to do:

(define (example x)
   ((define (is-even? x) (zero? (remainder x 2)))
    (define rofl "rolling on the floor laughing"))
   (if (is-even? x)
       (display rofl)
       (display ":("))))

It's a little baroque and definitely not "minimal", but neither is being able to do

(define (f x) ...)

when you could also do (define f (lambda (x) ...))

Unless otherwise credited all material copyright © 2010–2018 by Robert Smith