#!/usr/local/bin/guile -s !# ;;; $Id: wc.guile,v 1.7 2001/08/20 00:29:13 doug Exp $ ;;; http://www.bagley.org/~doug/shootout/ ;;; from Dale P. Smith (define (wc iport) (let ((chars 0) (words 0) (lines 0) (inword 0) (x #f)) (let loop () (set! x (read-char iport)) (if (eof-object? x) (begin (display lines) (display " ") (display words) (display " ") (display chars) (newline)) (begin (set! chars (+ 1 chars)) (if (not (char-whitespace? x)) (set! inword 1) (begin (set! words (+ words inword)) (set! inword 0) (if (char=? x #\newline) (set! lines (+ 1 lines))))) (loop)))))) (wc (current-input-port))