You are looking at historical revision 24994 of this page. It may differ significantly from its current revision.
A looping construct for processing input in a way similar to the awk tool.
Count non-comment lines in Scheme file:
(use awk) (print (awk (read-line) (line) ([nlines 0]) ("^[ \t]*;" nlines) (else (add1 nlines))))
Strip blank lines:
(use awk) (awk (read-line) (line) () ("[^ \t]" (print line)) )
Compute maximal line length:
(use awk) (print (awk (read-line) (line) ([max-len 0]) (#t (max max-len (string-length line))))
Sort /etc/passwd file:
(use awk) (define (read-passwd . port) (let ([line (apply read-line port)]) (if (eof-object? line) (values line #f) (values line (string-split-fields ":" line #:infix))))) (for-each (lambda (entry) (print (cdr entry))) (sort (awk (read-passwd) (line fields) ([ans '()]) (#t (cons (cons (car fields) line) ans)) ) (lambda (x y) (string<? (car x) (car y)))))
- 1.7 Bugfix release thanks to Imran Rafique for the report
- 1.6 Updated test script to return proper exit status
- 1.4 Improved unit tests
- 1.3 Added regex dependency
- 1.2 Ported to CHICKEN 4
- 1.1 Adapted to new setup scheme
- 1.0 Initial release
PLT Software Copyright (c) 1995-2002 PLT
PLT software is distributed under the GNU Lesser General Public License (LGPL).