Created
January 4, 2012 13:54
-
-
Save mattyw/1560170 to your computer and use it in GitHub Desktop.
J's under conjecture in clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;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