Created
September 17, 2010 18:39
-
-
Save anonymous/584718 to your computer and use it in GitHub Desktop.
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
(ns proj1) | |
(def letter-count (atom 0)) | |
(def number-count (atom 0)) | |
(def whitespace-count (atom 0)) | |
(defn count-everything [] | |
(map | |
#(cond | |
(Character/isDigit %) (swap! number-count inc) | |
(Character/isLetter %) (swap! letter-count inc) | |
(Character/isWhitespace %) (swap! whitespace-count inc)) | |
(slurp "test.txt"))) | |
(defn -main [] | |
(println "Decimal Values: ") | |
(map #(print-str (Character/getNumericValue %)) (slurp "test.txt")) | |
(println) | |
(count-everything) | |
(println "Letter count: " @letter-count) | |
(println "Number count: " @number-count) | |
(println "Whitespace count: " @whitespace-count)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment