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
(steam-roller [:a {1 2 3 4} 1 1 :a :a]) | |
-> ([:a {1 2, 3 4} 1 1 :a :a] :a {1 2, 3 4} 1 3 2 4 1 1 :a :a) | |
count: 11 | |
;;identityHashCodes: | |
(map #(System/identityHashCode %) (steam-roller [:a {1 2 3 4} 1 1 :a :a])) | |
(1460028191 | |
2005509007 | |
1545655515 | |
504432400 |
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
(ns clojurerng.core | |
(:import [com.modp.random LinearSunJDK]) | |
(:use [ criterium.core])) | |
(def ^:LinearSunJDK linsun (LinearSunJDK.)) | |
;;this is salvaged from | |
;; javarng.googlecode.com/svn/trunk/com/modp/random/LinearSunJDK.java | |
;;and the openJDK source code for .nextDouble |
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
;;create a lein new something | |
;;add [enlive "1.1.5"] to project.clj | |
;;lein repl: | |
(use 'net.cgrand.enlive-html) | |
;;define a simple template "inline" | |
(deftemplate abc | |
(java.io.StringReader. | |
"<html> |
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
(ns countertest) | |
(set *warn-on-reflection* true) | |
(def atom-cnt (atom 0)) | |
(time (dotimes [_ 1e6] (swap! atom-cnt inc))) | |
;; 156 ms | |
(def ^java.util.concurrent.atomic.AtomicInteger atomic-integer-counter (java.util.concurrent.atomic.AtomicInteger. 0)) |
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
;;trivial identites | |
[(+ ?x 0) ?x] | |
[(- ?x 0) ?x] | |
[(* ?x 1) ?x] | |
[(/ ?x 1) ?x] | |
[(* ?x 0) 0] | |
;;Math/pow | |
[(* ?x ?x) (Math/pow ?x 2) ] | |
[(* ?x ?x ?x) (Math/pow ?x 3) ] |
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
;;This is released under EPL (same as Clojure) and is most | |
;;welcomed to be included to Incanter or anything else | |
;;after some bettering (it would be nice to be able | |
;;to push DefaultXYZDatasets into the heat-map-thing | |
;;instead of function + xy-box | |
(ns heatmapfromarray | |
"show an vector-of-vectors without missing important parts of it" | |
(use [incanter core charts])) |
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
(use 'seesaw.core) | |
;; the state, when was the last keypress? | |
(def last-tap (atom nil)) | |
(defn nanoseconds-diff-to-bpm [now then] | |
(let [nanosecs-in-a-minute (* 60 1000 1000 1000.0) | |
diff (- now then)] | |
(/ nanosecs-in-a-minute diff))) |
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
(ns async-math) | |
(require '[clojure.core.async :as async :refer :all]) | |
(defn query-maker | |
"generates a simple math-query and the answer to it" | |
[] | |
(let [a (rand-int 10) b (rand-int 10)] | |
{:query (str "what is " a " + " b "?") | |
:answer (+ a b)})) |
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
(use 'hello) | |
(println "hello world!") |
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
java.util.concurrent.ExecutionException: java.lang.Error: Assert failed: (every? identity [key vtypeid cardinality]) | |
at datomic.common$throw_executionexception_if_throwable.invoke (common.clj:381) | |
datomic.common$promise$reify__253.get (common.clj:423) | |
datomic.common$promise$reify__253.deref (common.clj:431) | |
clojure.core$deref.invoke (core.clj:2117) | |
datomic.peer.Connection.transact (peer.clj:106) | |
datomic.api$transact.invoke (api.clj:63) | |
datest.core$eval935.invoke (NO_SOURCE_FILE:1) | |
clojure.lang.Compiler.eval (Compiler.java:6603) | |
clojure.lang.Compiler.eval (Compiler.java:6566) |