refine in-directory
example
Extend Juan's nice example to show simpler modes, too.
This commit is contained in:
parent
348cd7976f
commit
b5224743b8
|
@ -384,11 +384,7 @@ each element in the sequence.
|
||||||
content of a directory, use the result of @racket[directory-list] as
|
content of a directory, use the result of @racket[directory-list] as
|
||||||
a sequence.
|
a sequence.
|
||||||
|
|
||||||
@history[#:changed "6.0.0.1" @elem{Added @racket[use-dir?] argument.}]
|
@examples[
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(code:comment @#,t{Given a directory tree:})
|
(code:comment @#,t{Given a directory tree:})
|
||||||
(code:comment @#,t{})
|
(code:comment @#,t{})
|
||||||
(code:comment @#,t{ /example})
|
(code:comment @#,t{ /example})
|
||||||
|
@ -399,16 +395,38 @@ Examples:
|
||||||
(code:comment @#,t{ │ └── beta})
|
(code:comment @#,t{ │ └── beta})
|
||||||
(code:comment @#,t{ └── c})
|
(code:comment @#,t{ └── c})
|
||||||
(code:comment @#,t{})
|
(code:comment @#,t{})
|
||||||
(code:comment @#,t{Output:})
|
(eval:alts
|
||||||
(code:comment @#,t{})
|
(parameterize ([current-directory "/example"])
|
||||||
(code:comment @#,t{/example/c})
|
(for ([p (in-directory)])
|
||||||
(code:comment @#,t{/example/b})
|
(printf "~a\n" p)))
|
||||||
(code:comment @#,t{/example/b/beta})
|
(for ([p (in-list '("a"
|
||||||
(code:comment @#,t{/example/a})
|
"a/alpha"
|
||||||
(code:comment @#,t{})
|
"a/apple"
|
||||||
(let ([f (lambda (path) (regexp-match? #rx"/example/b.*" (path->string path)))])
|
"b"
|
||||||
(for ([p (in-directory "/example" f)])
|
"b/beta"
|
||||||
(printf "~a\n" p)))]}
|
"c"))])
|
||||||
|
(printf "~a\n" p)))
|
||||||
|
(eval:alts
|
||||||
|
(for ([p (in-directory "/example")])
|
||||||
|
(printf "~a\n" p))
|
||||||
|
(for ([p (in-list '("/example/a"
|
||||||
|
"/example/a/alpha"
|
||||||
|
"/example/a/apple"
|
||||||
|
"/example/b"
|
||||||
|
"/example/b/beta"
|
||||||
|
"/example/c"))])
|
||||||
|
(printf "~a\n" p)))
|
||||||
|
(eval:alts
|
||||||
|
(let ([f (lambda (path) (regexp-match? #rx"/example/b.*" path))])
|
||||||
|
(for ([p (in-directory "/example" f)])
|
||||||
|
(printf "~a\n" p)))
|
||||||
|
(for ([p (in-list '("/example/a"
|
||||||
|
"/example/b"
|
||||||
|
"/example/b/beta"
|
||||||
|
"/example/c"))])
|
||||||
|
(printf "~a\n" p)))]
|
||||||
|
|
||||||
|
@history[#:changed "6.0.0.1" @elem{Added @racket[use-dir?] argument.}]}
|
||||||
|
|
||||||
|
|
||||||
@defproc*[([(in-producer [producer procedure?])
|
@defproc*[([(in-producer [producer procedure?])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user