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
;; Before... | |
(defn find-samples-by-identifier | |
[identifier] | |
(:id (first @(-> (table config/*db* :samples) | |
(select (where (= :identifier identifier))))))) | |
;; After | |
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
(defwebtest link-integrity | |
(-> (GET "/") | |
(follow-link "Complications") | |
(follow-link "Add Results") | |
(success?) | |
(is))) |
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
(defwebtest normalization-data-test | |
(-> | |
(GET "/experiments/5") | |
(should-not-see "Cell Count") | |
(should-not-see "Phosphate Level") | |
(follow-link "Normalization") | |
(should-see "Cell Count"))) |
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 primes.core | |
(:gen-class)) | |
(defn bump-divisors-map | |
[divisors z] | |
(reduce | |
(fn [m p] | |
(let [y (+ z (* 2 p))] | |
(update-in m [y] conj p))) | |
(dissoc divisors z) |
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 do-stuff | |
[] | |
(send resource-agent register-resource-user) | |
(await resource-agent) | |
(do-stuff-with-resource) | |
(send resource-agent unregister-resource-user)) |
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
((comp | |
(partial apply partial) | |
(juxt (comp first list) (comp first list))) | |
(comp | |
(partial apply apply) | |
(juxt | |
(comp | |
(partial apply apply) | |
(juxt | |
(comp |
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 factorial | |
(comp | |
(partial apply apply) | |
(juxt | |
(comp | |
(partial apply comp) | |
(juxt | |
(comp | |
(partial apply partial) | |
(juxt (constantly apply) (constantly apply))) |
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 calculate-summary-statistics | |
[data-points] | |
(let [q (stats/quantile data-points)] | |
{:min (first q) | |
:twenty-fifth (second q) | |
:fiftieth (nth q 2) | |
:seventy-fifth (nth q 3) | |
:max (last q) | |
:mean (stats/mean q) | |
:median (stats/median )})) |
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
user=> (dotimes [_ 10] | |
(let [x (A. 1 2 3)] | |
(time | |
(dotimes [_ 1e8] | |
(.c ^A x))))) | |
"Elapsed time: 5.509002 msecs" | |
"Elapsed time: 0.080946 msecs" | |
"Elapsed time: 0.075289 msecs" | |
"Elapsed time: 0.07487 msecs" | |
"Elapsed time: 0.07494 msecs" |
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 timmc.core) | |
(defrecord A [x y z] | |
clojure.lang.IFn | |
(invoke [_ k] | |
(cond | |
(identical? k :x) x | |
(identical? k :y) y | |
(identical? k :z) z))) |