Skip to content

Instantly share code, notes, and snippets.

@mariussoutier
Created September 2, 2010 12: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 mariussoutier/562231 to your computer and use it in GitHub Desktop.
Save mariussoutier/562231 to your computer and use it in GitHub Desktop.
; 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