Sujet : Re: Style question
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 30. Jun 2025, 02:09:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103so49$1q4bt$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Rob Warnock wrote:
(defun file-forms (path)
"Sucks up an entire file from PATH into a list of forms (sexprs),
returning two values: the list of forms and the number of forms read."
(with-open-file (s path)
(loop with eof = (list :eof)
for form = (read s nil eof)
until (eq form eof)
collect form into forms
counting t into form-count
finally (return (values forms form-count)))))
Gauche Scheme
(use srfi-42) ;; list-ec
(define (file-forms file)
(let ((count 0))
(values
(call-with-input-file file
(lambda (inport)
(list-ec
(:port form inport read)
(begin (inc! count))
form)))
count)))