Created
November 5, 2011 21:37
-
-
Save nerdyworm/1342055 to your computer and use it in GitHub Desktop.
things all of them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun letter-freq (str) | |
(let ((ht (make-hash-table))) | |
(loop :for char :across str :do | |
(incf (gethash char ht 0))) | |
(maphash (lambda (k v) | |
(format t "~@C: ~D~%" k v)) | |
ht))) | |
(defun letter-freq-in-file (file) | |
(with-open-file (stream file) | |
(let ((str (make-string (file-length stream)))) | |
(read-sequence str stream) | |
(letter-freq str)))) | |
(letter-freq-in-file "test.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment