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:03 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:27 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)
(missing)
make-directory-files-generator hga@xxxxxx (06 Sep 2019 16:21 UTC)
Re: make-directory-files-generator hga@xxxxxx (06 Sep 2019 17:26 UTC)
(missing)
Re: make-directory-files-generator hga@xxxxxx (06 Sep 2019 21:56 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?