Re: [racket-users] Built-in way to list all children of a directory?

2017-06-27 Thread Ben Greenman
The predicate can be any function.

All files: `(find-files (lambda (x) #true) start-path)`
All pdf files: `(find-files (lambda (x) (equal? #".pdf" (path-get-extension
x))) some-path)`

There's also the `file/glob` module.
All pdf files: `(glob (build-path some-path "**" "*.pdf"))`
Iterator for all files: `(in-glob (build-path some-path "**"))`

On Tue, Jun 27, 2017 at 10:17 PM, Glenn Hoetker  wrote:

> Struggling as a newbie with the documentation for find-files. In
> particular, the "predicate" part of
>
> (find-files
> predicate
>  [  start-path]
> #:skip-filtered-directory? skip-filtered-directory?
> #:follow-links? follow-links?)
>
> Can anyone offer a working example?  All file, all pdfs. Doesn't really
> matter. Just something concrete to get me started. Many thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Built-in way to list all children of a directory?

2017-06-27 Thread Glenn Hoetker
Struggling as a newbie with the documentation for find-files. In particular, 
the "predicate" part of 

(find-files  
predicate
 [  start-path]  
#:skip-filtered-directory? skip-filtered-directory?  
#:follow-links? follow-links?)

Can anyone offer a working example?  All file, all pdfs. Doesn't really matter. 
Just something concrete to get me started. Many thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Built-in way to list all children of a directory?

2017-06-27 Thread Matthew Flatt
At Tue, 27 Jun 2017 18:31:21 -0700 (PDT), Glenn Hoetker wrote:
> As far as I can tell, (directory-list some-path) yields a list of
> files and directories immediately below some-path. I wish to capture
> all files and directories in some-path or any of the sub-directories
> of some-path.

I would use `in-directory` with one of the `for` forms, but see also
`find-files` and `fold-files`.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Built-in way to list all children of a directory?

2017-06-27 Thread Matthew Butterick

> On Jun 27, 2017, at 6:31 PM, Glenn Hoetker  > wrote:
> 
> Naive question, here.  As far as I can tell, (directory-list some-path) 
> yields a list of files and directories immediately below some-path. I wish to 
> capture all files and directories in some-path or any of the sub-directories 
> of some-path.  

`in-directory`, which is designed to be used within a `for` loop:

http://docs.racket-lang.org/reference/sequences.html?q=in-directory#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._in-directory%29%29
 


Use with `for/list` if you want to gather the results into a list.

Use `#:when` to restrict the results.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Built-in way to list all children of a directory?

2017-06-27 Thread Glenn Hoetker
Naive question, here.  As far as I can tell, (directory-list some-path) yields 
a list of files and directories immediately below some-path. I wish to capture 
all files and directories in some-path or any of the sub-directories of 
some-path.  I didn't find an obvious option for doing so. Before I write my 
own--probably inefficient--way of doing so, I wanted to ask if there was a 
built-in command that would yield all the children of a path.  Many thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.