Skip to content

Instantly share code, notes, and snippets.

@bpsm
Created December 21, 2010 20:02
Show Gist options
  • Save bpsm/750485 to your computer and use it in GitHub Desktop.
Save bpsm/750485 to your computer and use it in GitHub Desktop.
(defn interval [x y] [x y])
(defn plus [[a b] [c d]] [(+ a c) (+ b d)])
(defn minus [[a b] [c d]] [(- a d) (- b c)])
(def minmax (juxt min max))
(defn times [[a b] [c d]] (minmax (* a c) (* a d) (* b c) (* b d)))
(defn divide [[a b] [c d]] (minmax (/ a c) (/ a d) (/ b c) (/ b d)))
(def half #(/ % 2))
(defn ends->center [[a b]] [(half (+ a b)) (half (- b a))])
(defn center->ends [[a b]] [(- a b) (+ a b)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment