fix #<undefined> mention and adjust example to always terminate

This commit is contained in:
Robby Findler 2014-05-04 20:53:09 -05:00
parent 9613d45566
commit 1ce09cf924
2 changed files with 19 additions and 12 deletions

View File

@ -237,7 +237,7 @@ Internal definitions in a particular @racket[_body] sequence are
mutually recursive; that is, any definition can refer to any other
definition---as long as the reference isn't actually evaluated before
its definition takes place. If a definition is referenced too early,
the result is a special value @|undefined-const|.
an error occurs.
@defexamples[
(define (weird)

View File

@ -129,26 +129,33 @@ The @racket[_expr]s in a @racket[letrec] form are most often
]
@interaction[
(letrec ([tarzan-in-tree?
(lambda (name path)
(letrec ([tarzan-near-top-of-tree?
(lambda (name path depth)
(or (equal? name "tarzan")
(and (directory-exists? path)
(tarzan-in-directory? path))))]
(tarzan-in-directory? path depth))))]
[tarzan-in-directory?
(lambda (dir)
(ormap (lambda (elem)
(tarzan-in-tree? (path-element->string elem)
(build-path dir elem)))
(directory-list dir)))])
(tarzan-in-tree? "tmp" (find-system-path 'temp-dir)))
(lambda (dir depth)
(cond
[(zero? depth) #f]
[else
(ormap
(λ (elem)
(tarzan-near-top-of-tree? (path-element->string elem)
(build-path dir elem)
(- depth 1)))
(directory-list dir))]))])
(tarzan-near-top-of-tree? "tmp"
(find-system-path 'temp-dir)
4))
]
While the @racket[_expr]s of a @racket[letrec] form are typically
@racket[lambda] expressions, they can be any expression. The
expressions are evaluated in order, and after each value is obtained,
it is immediately associated with its corresponding @racket[_id]. If
an @racket[_id] is referenced before its value is ready, the result is
@|undefined-const|, just as for internal definitions.
an @racket[_id] is referenced before its value is ready, an
error is raised, just as for internal definitions.
@interaction[
(letrec ([quicksand quicksand])