Skip to content

Instantly share code, notes, and snippets.

@tahmidsadik
Last active August 29, 2015 14:07
Show Gist options
  • Save tahmidsadik/49fadc74d8d2e09e09fb to your computer and use it in GitHub Desktop.
Save tahmidsadik/49fadc74d8d2e09e09fb to your computer and use it in GitHub Desktop.
Extracts number from string and adds them up.
(use '[clojure.string :only (split)])
(def s "96h11k4959q615948s50922o38h1453ij38w73413d5577lzrqw3780b389750vf100zd29z73j5wh73l6965n85vm77cw10awrjr29265289222238n10013uk10062f9449acbhfgcm35j78q80")
(defn num-parser [ls]
(split ls #""))
(defn num? [x]
(if (= x "") false (number? (read-string x))))
(reduce +(map #(Integer/parseInt %)(filter num? (num-parser s))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment