Created
September 2, 2010 12:39
-
-
Save mariussoutier/562231 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
; It's a thing of beauty how easy it is to parse therapy intervals in Clojure. | |
; Therapy intervals are usually Strings like 1-0-3-0 or 1-0.5-1 to describe how many pills a patient is taking every day | |
(defn interval-value [interval] "Parses an interval String and returns its numerical value" | |
(reduce + (map #(Double/valueOf %) (re-seq #"[0-9]+(?:[\\.][0-9]+)?" interval)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment