fix #<undefined> mention and adjust example to always terminate
This commit is contained in:
parent
9613d45566
commit
1ce09cf924
|
@ -237,7 +237,7 @@ Internal definitions in a particular @racket[_body] sequence are
|
||||||
mutually recursive; that is, any definition can refer to any other
|
mutually recursive; that is, any definition can refer to any other
|
||||||
definition---as long as the reference isn't actually evaluated before
|
definition---as long as the reference isn't actually evaluated before
|
||||||
its definition takes place. If a definition is referenced too early,
|
its definition takes place. If a definition is referenced too early,
|
||||||
the result is a special value @|undefined-const|.
|
an error occurs.
|
||||||
|
|
||||||
@defexamples[
|
@defexamples[
|
||||||
(define (weird)
|
(define (weird)
|
||||||
|
|
|
@ -129,26 +129,33 @@ The @racket[_expr]s in a @racket[letrec] form are most often
|
||||||
]
|
]
|
||||||
|
|
||||||
@interaction[
|
@interaction[
|
||||||
(letrec ([tarzan-in-tree?
|
(letrec ([tarzan-near-top-of-tree?
|
||||||
(lambda (name path)
|
(lambda (name path depth)
|
||||||
(or (equal? name "tarzan")
|
(or (equal? name "tarzan")
|
||||||
(and (directory-exists? path)
|
(and (directory-exists? path)
|
||||||
(tarzan-in-directory? path))))]
|
(tarzan-in-directory? path depth))))]
|
||||||
[tarzan-in-directory?
|
[tarzan-in-directory?
|
||||||
(lambda (dir)
|
(lambda (dir depth)
|
||||||
(ormap (lambda (elem)
|
(cond
|
||||||
(tarzan-in-tree? (path-element->string elem)
|
[(zero? depth) #f]
|
||||||
(build-path dir elem)))
|
[else
|
||||||
(directory-list dir)))])
|
(ormap
|
||||||
(tarzan-in-tree? "tmp" (find-system-path 'temp-dir)))
|
(λ (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
|
While the @racket[_expr]s of a @racket[letrec] form are typically
|
||||||
@racket[lambda] expressions, they can be any expression. The
|
@racket[lambda] expressions, they can be any expression. The
|
||||||
expressions are evaluated in order, and after each value is obtained,
|
expressions are evaluated in order, and after each value is obtained,
|
||||||
it is immediately associated with its corresponding @racket[_id]. If
|
it is immediately associated with its corresponding @racket[_id]. If
|
||||||
an @racket[_id] is referenced before its value is ready, the result is
|
an @racket[_id] is referenced before its value is ready, an
|
||||||
@|undefined-const|, just as for internal definitions.
|
error is raised, just as for internal definitions.
|
||||||
|
|
||||||
@interaction[
|
@interaction[
|
||||||
(letrec ([quicksand quicksand])
|
(letrec ([quicksand quicksand])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user