Created
May 5, 2011 21:27
-
-
Save odyssomay/958001 to your computer and use it in GitHub Desktop.
Comparable function type
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
(deftype CFn [f form] | |
clojure.lang.IFn | |
(invoke [this x1] ((.f this) x1)) | |
(invoke [this x1 x2] ((.f this) x1 x2)) | |
(invoke [this x1 x2 x3] ((.f this) x1 x2 x3)) | |
(invoke [this x1 x2 x3 x4] ((.f this) x1 x2 x3 x4)) | |
(invoke [this x1 x2 x3 x4 x5] ((.f this) x1 x2 x3 x4 x5)) | |
(invoke [this x1 x2 x3 x4 x5 x6] ((.f this) x1 x2 x3 x4 x5 x6)) | |
(invoke [this x1 x2 x3 x4 x5 x6 x7] ((.f this) x1 x2 x3 x4 x5 x6 x7)) | |
; and so on.... | |
(applyTo [this arglist] | |
(apply (.f this) arglist)) | |
java.lang.Object | |
(equals [this other_fn] | |
(if (and (= (class other_fn) (class this)) | |
(= (.form this) (.form other_fn))) | |
true false))) | |
(defmacro c-fn [& forms] | |
`(CFn. (fn ~@forms) '~forms)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment