View transducerfun.clj
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
(require '[clojure.core.async :as a]) | |
(def xform (comp (map inc) | |
(filter even?) | |
(dedupe) | |
(flatmap range) | |
(partition-all 3) | |
(partition-by #(< (apply + %) 7)) | |
(flatmap flatten) | |
(random-sample 1.0) |
View mapperf.clj
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 bitmapmap-test.core-test | |
(:use clojure.test)) | |
#_(defn bitmap-map | |
"Constructs a bitmap-map. If any keys are equal, they are handled as | |
if by repeated uses of assoc." | |
{:added "1.6" | |
:static true} | |
([] (. clojure.lang.PersistentBitmapMap EMPTY)) | |
([& keyvals] |
View codeq-examples.clj
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
(require '[datomic.api :as d]) | |
(require '[clojure.pprint :refer [pprint]]) | |
(def uri "datomic:free://localhost:4334/git") | |
(def conn (d/connect uri)) | |
(def db (d/db conn)) | |
;; committers | |
(d/q '[:find ?email | |
:where | |
[_ :commit/committer ?u] |
View thread.clj
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
(defmacro test-> | |
"Takes an expression and a set of test/form pairs. Threads expr (via ->) | |
through each form for which the corresponding test expression (not threaded) is true." | |
[expr | |
& clauses] | |
(assert (even? (count clauses))) | |
(let [g (gensym) | |
pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))] | |
`(let [~g ~expr | |
~@(interleave (repeat g) (map pstep (partition 2 clauses)))] |
View bintree.clj
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
;; The Computer Language Benchmarks Game | |
;; http://shootout.alioth.debian.org/ | |
; | |
;; Adapted from the Java -server version | |
; | |
;; contributed by Marko Kocic | |
;; modified by Kenneth Jonsson, restructured to allow usage of 'pmap' | |
;; modified by Andy Fingerhut to use faster primitive math ops, and | |
;; deftype instead of defrecord for smaller tree nodes. | |
;; https://github.com/jafingerhut/clojure-benchmarks/blob/master/binarytrees/binarytrees.clj-4.clj modified by RH for 1.3 |
View gist:605527
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
SEND | |
destination:/queue/a | |
{:code (prn "Hello world")} | |
^@ |
View gist:440102
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
;new num branch results | |
(defn fib [n] | |
(if (>= 1 n) | |
1 | |
(+ (fib (dec n)) (fib (- n 2))))) | |
(time (fib 38)) | |
"Elapsed time: 3716.828 msecs" |
View gist:432465
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
(defn ^:static fib ^long [^long n] | |
(if (>= (long 1) n) | |
(long 1) | |
(+ (fib (dec n)) (fib (- n (long 2)))))) | |
(dotimes [_ 10] (time (fib 38))) |
View gist:430205
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
[java] FAIL in (test-annotations) (test_clojure.clj:92) | |
[java] Parameter annotations: void foo(@Retention(?) String) | |
[java] expected: (instance? Retention retention) | |
[java] actual: $Proxy2 | |
[java] | |
[java] FAIL in (test-annotations) (test_clojure.clj:92) | |
[java] Parameter annotations: void foo(@Target(?) String) | |
[java] expected: (instance? Target target) | |
[java] actual: $Proxy1 | |
[java] |
View gist:377213
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
;annotation syntax | |
(import [java.lang.annotation Retention RetentionPolicy Target ElementType] | |
[javax.xml.ws WebServiceRef WebServiceRefs]) | |
(definterface Foo (foo [])) | |
;annotation on type | |
(deftype ^{Deprecated true | |
Retention RetentionPolicy/RUNTIME | |
javax.annotation.processing.SupportedOptions ["foo" "bar" "baz"] |
NewerOlder