Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Referential Transparency
(filter even? (range 10))
;; equals
(new clojure.lang.LazySeq
(fn []
[s (. clojure.lang.RT
(seq (new clojure.lang.LazySeq
#(let [b (clojure.lang.ChunkBuffer. 32)
comp (if (let [a (. clojure.lang.Numbers (isZero 1))]
(if a a (clojure.lang.Util/equiv 0 10)))
(if (. clojure.lang.Numbers (isPos 1))
(if (. clojure.lang.Numbers (isNeg 1))
(loop* [i 0]
(if (let [a (< (clojure.lang.RT/count b) 32)]
(if a (comp i 10) a))
(do (.add b i)
(recur (. clojure.lang.Numbers (add i 1))))
(.chunk b)
(if (comp i 10) (do (range i 10 1))))))))))]
(if (instance? clojure.lang.IChunkedSeq s)
(let [c (.chunkedFirst s)
size (clojure.lang.RT/count c)
b (clojure.lang.ChunkBuffer. size)]
(let [xy (clojure.lang.RT/longCast size)]
(loop* [i 0]
(if (. clojure.lang.Numbers (lt i xy))
(if (if (or (instance? Integer (.nth c i))
(instance? Long (.nth c i))
(instance? clojure.lang.BigInt (.nth c i))
(instance? BigInteger (.nth c i))
(instance? Short (.nth c i))
(instance? Byte (.nth c i)))
(. clojure.lang.Numbers
(. clojure.lang.Numbers
(clojure.lang.RT/uncheckedLongCast (.nth c i))
(throw (IllegalArgumentException. (str "Argument must be an integer: " (.nth c i)))) )
(do (.add b (.nth c i))))
(recur (. clojure.lang.Numbers (unchecked_inc i)))))))
(chunk-cons (.chunk b) (filter even? (.chunkedMore s))))
(let [f (. clojure.lang.RT (first s))
r (. clojure.lang.RT (more s))]
(if (if (or (instance? Integer f)
(instance? Long f)
(instance? clojure.lang.BigInt f)
(instance? BigInteger f)
(instance? Short f)
(instance? Byte f))
(. clojure.lang.Numbers
(. clojure.lang.Numbers
(clojure.lang.RT/uncheckedLongCast f)
(throw (IllegalArgumentException. (str "Argument must be an integer: " f))) )
(. clojure.lang.RT (cons f (filter even? r)))
(filter even? r)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.