Prev Up Next
We used the begin special form to bunch together a
group of subforms that need to be evaluated in
sequence. Many Scheme forms have implicit
begins. For example, let's define a 3-argument procedure that
displays its three arguments, with spaces between
them. A possible definition is:
(define display3
(lambda (arg1 arg2 arg3)
(begin
(display arg1)
(display " ")
(display arg2)
(display " ")
(display arg3)
(newline))))
In Scheme, lambda-bodies are implicit begins.
Thus, the begin in display3's body isn't needed, although it doesn't
hurt. display3, more simply, is:
(define display3
(lambda (arg1 arg2 arg3)
(display arg1)
(display " ")
(display arg2)
(display " ")
(display arg3)
(newline)))
Prev Up Next