#+clisp (progn (defvar *eol* (encoding-line-terminator *default-file-encoding*)) (setf *default-file-encoding* (make-encoding :charset "iso-8859-1" :line-terminator *eol*)) (setf *standard-input* (make-stream :input)) (setf *standard-output* (make-stream :output))) (defvar *score* (make-hash-table :test 'equal)) (defvar *words* nil) (loop for line = (read-line nil nil) while line do (let ((p 0) (gap t)) (dotimes (q (length line)) (if (char/= (char line q) #\Space) (when gap (setq p q) (setq gap nil)) (unless gap (incf (gethash (subseq line p q) *score* 0)) (setq gap t)))) (unless gap (incf (gethash (subseq line p) *score* 0))))) (maphash (lambda (word count) (push word *words*)) *score*) (dolist (word (sort *words* 'string<)) (format t "~A ~A~%" word (gethash word *score*)))