- line-numbers #!optional <start>procedure
A convenience utility, just formats an infinite stream of numbers (in the current radix) beginning with <start>, which defaults to 1.
The Unix nl(1) utility could be implemented as:
(fmt #t (columnar 6 'right 'infinite (line-numbers) " " (fmt-file "read-line.scm")))
1 2 (define (read-line . o) 3 (let ((port (if (pair? o) (car o) (current-input-port)))) 4 (let lp ((res '())) 5 (let ((c (read-char port))) 6 (if (or (eof-object? c) (eqv? c #\newline)) 7 (list->string (reverse res)) 8 (lp (cons c res)))))))