Quick question about SRFI-170 directory-files hga@xxxxxx 29 Jul 2019 15:46 UTC
(missing)
(missing)
Re: Quick question about SRFI-170 directory-files hga@xxxxxx 29 Jul 2019 17:08 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 17:42 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 17:51 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:02 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:15 UTC
Put directory-fold in the SRFI? hga@xxxxxx 29 Jul 2019 18:45 UTC
Re: Put directory-fold in the SRFI? John Cowan 29 Jul 2019 19:38 UTC
Re: Quick question about SRFI-170 directory-files John Cowan 29 Jul 2019 20:26 UTC
Re: Quick question about SRFI-170 directory-files Marc Feeley 29 Jul 2019 18:28 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:31 UTC
Re: Quick question about SRFI-170 directory-files Marc Feeley 29 Jul 2019 18:46 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:57 UTC
Re: Quick question about SRFI-170 directory-files Marc Feeley 29 Jul 2019 19:04 UTC
Re: Quick question about SRFI-170 directory-files hga@xxxxxx 29 Jul 2019 18:32 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:51 UTC
Re: Quick question about SRFI-170 directory-files hga@xxxxxx 29 Jul 2019 19:16 UTC
Re: Quick question about SRFI-170 directory-files John Cowan 30 Jul 2019 18:52 UTC
Re: Quick question about SRFI-170 directory-files hga@xxxxxx 30 Jul 2019 19:58 UTC
Re: Quick question about SRFI-170 directory-files John Cowan 30 Jul 2019 20:44 UTC
Outstanding issue: directory-files in the context of huge directories hga@xxxxxx 03 Sep 2019 21:03 UTC
(missing)
Fwd: Outstanding issue: directory-files in the context of huge directories John Cowan 04 Sep 2019 12:20 UTC
Re: Outstanding issue: directory-files in the context of huge directories Marc Feeley 04 Sep 2019 12:31 UTC
Re: Outstanding issue: directory-files in the context of huge directories John Cowan 04 Sep 2019 13:56 UTC
Re: Outstanding issue: directory-files in the context of huge directories Marc Feeley 04 Sep 2019 14:08 UTC
make-directory-files-generator hga@xxxxxx 06 Sep 2019 16:21 UTC
Re: make-directory-files-generator hga@xxxxxx 06 Sep 2019 17:24 UTC
(missing)
Re: make-directory-files-generator hga@xxxxxx 06 Sep 2019 21:56 UTC
Re: Outstanding issue: directory-files in the context of huge directories Lassi Kortela 04 Sep 2019 11:46 UTC
Re: Outstanding issue: directory-files in the context of huge directories Lassi Kortela 04 Sep 2019 11:52 UTC
Re: Outstanding issue: directory-files in the context of huge directories hga@xxxxxx 04 Sep 2019 12:13 UTC
Re: Outstanding issue: directory-files in the context of huge directories Lassi Kortela 04 Sep 2019 12:26 UTC
Re: Outstanding issue: directory-files in the context of huge directories John Cowan 04 Sep 2019 12:30 UTC
Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:06 UTC

Re: Quick question about SRFI-170 directory-files Lassi Kortela 29 Jul 2019 18:15 UTC

> In Scheme we could go even further and leave out the user-supplied 'n'
> argument. The implementation could choose how many entries it returns at
> one time, according to whatever is most convenient for FFI and GC.

OK so a version of Chibi's directory-fold...

(directory-fold dir kons knil)

... that gets lists instead of individual names.

Get all files in the directory:

(directory-fold dir append '())

Filter them:

(import (srfi 1))
(directory-fold
     dir
     (lambda (new-names so-far)
       (append so-far (filter not-a-dotfile? new-names)))
     '())

Gather into a hash table:

(import (srfi 69))
(directory-fold
     dir
     (lambda (new-names ht)
       (for-each (lambda (name)
                   (hash-table-set! ht name (get-some-info dir name)))
                 new-names)
       ht)
     (make-hash-table))

Get only some files:

(directory-fold
     dir
     (lambda (new-names so-far)
       (if (>= (length so-far) 10)
           so-far
           (append so-far new-names)))
     '())

Only count the files:

(directory-fold
     dir
     (lambda (new-names count) (+ count (length new-names)))
     0)

What do you think?