Instantly share code, notes, and snippets.

What would you like to do?
; 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