Skip to content

Instantly share code, notes, and snippets.

Created September 17, 2010 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/584718 to your computer and use it in GitHub Desktop.
Save anonymous/584718 to your computer and use it in GitHub Desktop.
(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