Question

The Racket Docs state that the lambda function can be invoked with multiple arguments after the body argument, e.g.:

((lambda () (display "foo") (display "bar")))

prints foobar.

How exactly does this work? I didn't find any explanation in the racket documentation. Did I miss something?

Was it helpful?

Solution

Procedure bodies have an implicit begin. Thus

(lambda ()
  (foo)
  (bar))

is treated as if the same as

(lambda ()
  (begin
    (foo)
    (bar)))

See Sequencing in the Racket guide for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top