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
=> ,(time (apply (fn [a b c] (+ a b c)) (map deref [(future (Thread/sleep 1000) 1) (future (Thread/sleep 1000) 2) (future (Thread/sleep 1000) 3)]))) | |
"Elapsed time: 1000.790535 msecs" | |
6 |
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
<html> | |
... | |
<body> | |
<script src="cljs-js/app.js"></script> | |
<script> | |
Stripe.setPublishableKey('{{stripekey}}'); | |
window.kingfisher_environment = {{{environment}}}; | |
kingfisher.core.start(); | |
</script> | |
</body> |
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
kingfisher.core=> (defprotocol LazyDelay (default [this x])) | |
LazyDelay | |
kingfisher.core=> (extend-protocol LazyDelay clojure.lang.Delay (default [this x] (if (realized? this) @this x))) | |
nil | |
kingfisher.core=> (def d (delay 42)) | |
#'kingfisher.core/d | |
kingfisher.core=> (default d 12) | |
12 | |
kingfisher.core=> @d | |
42 |
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
Clojure 1.8.0 | |
+user=> (def a (atom nil)) | |
#'user/a | |
+user=> (def s (atom [])) | |
#'user/s | |
+user=> (add-watch a :state-watcher (fn [_ _ _ n] (swap! s conj n))) | |
#object[clojure.lang.Atom 0x928763c {:status :ready, :val nil}] | |
+user=> (swap! a conj :initial) | |
(:initial) | |
+user=> @s |
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
user=> (ns foo.bar) | |
nil | |
foo.bar=> (defprotocol Baz (quux [this])) | |
Baz | |
foo.bar=> (ns foo.baz) | |
nil | |
foo.baz=> (defprotocol Bar (quux [this])) | |
Bar | |
foo.baz=> (in-ns 'user) | |
#object[clojure.lang.Namespace 0x2847f343 "user"] |
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
peregrine.circle=> (binding [*warn-on-reflection* true *unchecked-math* :warn-on-boxed] (eval '(fn [] (rand-int)))) | |
#object[peregrine.circle$eval33277$fn__33278 0x1da5063e "peregrine.circle$eval33277$fn__33278@1da5063e"] | |
peregrine.circle=> (def a 1) | |
#'peregrine.circle/a | |
peregrine.circle=> (binding [*warn-on-reflection* true *unchecked-math* :warn-on-boxed] (eval '(fn [] (rand-int)))) | |
#object[peregrine.circle$eval33283$fn__33284 0x3e49d47f "peregrine.circle$eval33283$fn__33284@3e49d47f"] | |
peregrine.circle=> (binding [*warn-on-reflection* true *unchecked-math* :warn-on-boxed] (eval '(fn [] (+ 1 (rand-int))))) | |
Boxed math warning, /private/var/folders/_m/9py48m892rq93bgbc91br8mr0000gr/T/form-init366749289092648620.clj:1:84 - call: public static java.lang.Number clojure.lang.Numbers.unchecked_add(long,java.lang.Object). | |
#object[peregrine.circle$eval33289$fn__33290 0x32cc6003 "peregrine.circle$eval33289$fn__33290@32cc6003"] |
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 org.noisesmith.range-transducer) | |
(defn trange | |
([transform] | |
(trange transform 0 nil 1 (constantly nil))) | |
([transform final] | |
(trange transform 0 final 1 >=)) | |
([transform init final] | |
(trange transform init final 1 >=)) | |
([transform init final step] |
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
(defn anagrams? | |
[& args] | |
(let [alpha (map char (range (int \a) (inc (int \z)))) | |
metrics (map (comp #(select-keys % alpha) | |
frequencies | |
clojure.string/lower-case) | |
args)] | |
(or (apply = metrics) | |
(let [result-keys (reduce into #{} (map keys metrics)) | |
empty-result (zipmap result-keys (repeat 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
(defn debug-file | |
([file-name data] | |
(debug-file file-name data {})) | |
([file-name data replacements] | |
(assert (or (string? file-name) | |
(symbol? file-name)) | |
"file name?") | |
(assert (map? replacements) | |
"map of data type replacements please") | |
(let [out-to (str file-name '.edn) |
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
$ ./test-clojure-versions '(+ 1 1)' | |
clojure 1.8.0 | |
2 | |
clojure 1.7.0 | |
2 | |
clojure 1.6.0 | |
2 | |
clojure 1.5.1 | |
2 | |
clojure 1.3.0 |