#| Print the word-frequency count of a file, sorted by frequency. | Invoked with one argument (a filename), and prints to stdout. | @see http://www.cs.duke.edu/csed/code/, for problem spec. | Run with plt-scheme; see 'usage' at end of this file. | | @author Ian Barland | @version 2007.Mar.22 |# (require (lib "plt-pretty-big-text.ss" "lang")) (require (lib "pregexp.ss")) ; for "split" ;; An "entry" is a dotted-pair, (cons ). ;; For example, (cons "raven" 3) indicates that the word "raven" ;; has been seen 3 times. ;; Print one entry as a line in the require format. ;; (define (print-entry e) (printf "~a\t~a\n" (rest e) (first e))) ;; Compare two entries: By decreasing count, ;; with ties broken by increasing words (alphabetically). ;; (define (entry-greater-than? e1 e2) (cond [(> (rest e1) (rest e2)) true ] [(< (rest e1) (rest e2)) false] [else (string