Skip to content

Instantly share code, notes, and snippets.

@mattyw
Created January 4, 2012 13:54
Show Gist options
  • Save mattyw/1560170 to your computer and use it in GitHub Desktop.
Save mattyw/1560170 to your computer and use it in GitHub Desktop.
J's under conjecture in clojure
;;Will Suffer from rounding errors - but ok for an example
(defn under [verb, obverse, func x y]
(obverse (func (verb x) (verb y))))
(defn log [x]
(Math/log x))
(defn exp [x]
(Math/exp x))
(defn my-multiply [x y]
(under log exp + x y))
(defn my-add [x y]
(under exp log * x y))
(println (my-multiply 2 3))
(println (my-multiply 2 2))
(println (my-add 1 2))
(println (my-add 3 3))
(println (my-add 3 4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment