utils: Add list-contents and almost-basename procedures

pull/3/head
Luis Guilherme Coelho 2024-07-07 16:35:10 -03:00
parent 9b81802b1a
commit e21427c872
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
1 changed files with 14 additions and 1 deletions

View File

@ -2,9 +2,12 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:use-module (ice-9 ftw)
#:export (associate-left
associate-right
flat-map))
flat-map
list-contents
almost-basename))
(define-syntax-rule
(associate-left (key associations) ...)
@ -26,3 +29,13 @@ list, up to the last list."
(lambda arglst (apply proc h arglst))
tail-lsts))
head-lst))))
(define (list-contents dir)
(and=> (scandir dir)
(lambda (subdirs)
(map (cut string-append dir "/" <>)
(cddr subdirs)))))
(define (almost-basename file)
(string-append (basename (dirname file))
"/" (basename file)))