[plt-scheme] Local function definition

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sun Jan 11 21:30:40 EST 2004

At Sun, 11 Jan 2004 20:18:57 -0500 (EST), Guillaume Marceau wrote:
> Does that means there is no define-like special form for local definitions?

Oh, no. Just use internal definitions. Their syntax is a little wierd
-- unlike unit definitions and class definitions, you cannot comingle
definitions and expressions (all definitions must come first), but you
can certainly put definitions inside a lambda and a let (and inside a
definition that hides a lambda):

(define (find-short-path graph red-nodes blue-nodes)
  (define (get-siblings loci)
     (map (lambda (sibling) (make-loci sibling (loci-stack loci)))
          (graph-adjs graph (loci-node loci))))])
  ...)

Check out r5rs on internal definitions.

Robby


Posted on the users mailing list.