The seasoned schemer on page 78 has the below definition of leftmost
and lm
.
(define leftmost
(lambda (l)
(letcc skip
(lm l skip))))
(define lm
(lambda (l out)
(cond
((null? l) (quote ()))
((atom? (car l)) (out (car l)))
(else (let ()
(lm (car l) out)
(lm (cdr l) out))))))
On the next page it has the following explanation of having multiple expressions in the value part. I don't understand the explanation of how it makes leftmost
work on, for example (() a)
.
When a (let ...) has two expressions in its value part, we must first determine the value of the first expression. If it has one, we ignore it and determine the value of the second expression."