This file contains 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
(ns strangeness.fn-arity | |
(:import java.lang.reflect.Method)) | |
(defn declared-methods [^Class class] | |
(filter #(= class (.getDeclaringClass ^Method %)) | |
(.getMethods class))) | |
(defn has-arity? [fun arity] | |
(let [cls (class fun) | |
methods (declared-methods cls)] |
This file contains 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
(def foo (fn foo [x] | |
(if (zero? x) | |
x | |
(foo (dec x))))) | |
(dotimes [i 3] | |
(println "lexical binding run" i) | |
(time | |
(dotimes [i 1000] | |
(foo i)))) |
This file contains 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
(def fib-var-obj | |
(fn [x] | |
(if (< x 2) | |
1 | |
(+ (fib-var-obj (- x 1)) | |
(fib-var-obj (- x 2)))))) | |
(defn fib-lex-obj [x] | |
(if (< x 2) | |
1 |
OlderNewer