Skip to content

Instantly share code, notes, and snippets.

@Anderssorby
Created July 3, 2016 10:37
Show Gist options
  • Save Anderssorby/3d02c99f1655756a448a39dcc60c58f7 to your computer and use it in GitHub Desktop.
Save Anderssorby/3d02c99f1655756a448a39dcc60c58f7 to your computer and use it in GitHub Desktop.
;; An infix calculator
(defn calc [& x]
(loop [a (first x) b (second x) c (nth x 2) remainding (drop 3 x)] ;; This loop is unnecessary complex
(let [result (b a c)]
(if (empty? remainding)
result
(recur
result
(first remainding)
(second remainding)
(drop 2 remainding)
)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment