; This program uses SLIB - a portable scheme library (require 'hash-table) (require 'sort) (require 'stdio) (define hash-get (hash-inquirer string=?)) (define hash-set (hash-associator string=?)) (define (hash-incr h key) (let ((val (hash-get h key))) (hash-set h key (if val (+ 1 val) 1)))) (define total (make-hash-table 100003)) (define words '()) (do ((word-or-nil (scanf-read-list " %s") (scanf-read-list " %s"))) ((null? word-or-nil)) (hash-incr total (car word-or-nil))) (hash-for-each (lambda (word count) (set! words (cons word words))) total) (for-each (lambda (word) (printf "%s %d\n" word (hash-get total word))) (sort! words string