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 fun-with-quil.breezy | |
(:use quil.core)) | |
(set! *unchecked-math* true) | |
(def ^:constant screen-w 1920) | |
(def ^:constant screen-h 1080) | |
(defn r ^double [^long x ^long y] | |
(loop [k 0 i 0.0 j 0.0)] |
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
private IFn findAndCacheBestMethod(Object dispatchVal) { | |
rw.readLock().lock(); | |
Object bestValue; // remember the best match IFn | |
IPersistentMap mt = methodTable; | |
IPersistentMap pt = preferTable; | |
Object ch = cachedHierarchy; | |
try | |
{ | |
Map.Entry bestEntry = null; | |
for(Object o : getMethodTable()) |
This file has been truncated, but you can view the full file.
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
Compiled from "eclipse.clj" | |
public final class ccw.eclipse$goto_editor_line extends clojure.lang.AFunction { | |
public static final clojure.lang.Var const__0; | |
public static final clojure.lang.Var const__1; | |
public static final clojure.lang.Keyword const__2; | |
public static final clojure.lang.Keyword const__3; |
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
compare perf of reduce and mapv on small vectors - testing worst case of size 6 | |
## 1.7.0 | |
vecperf.bench=> (def v [0 1 2 3 4 5]) | |
#'vecperf.bench/v | |
vecperf.bench=> (quick-bench (reduce + 0 v)) | |
WARNING: Final GC required 1.508801076780115 % of runtime | |
WARNING: Final GC required 13.47335649374595 % of runtime | |
Evaluation count : 11114412 in 6 samples of 1852402 calls. |
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
; What function can I put as FOO here to yield true | |
; Tried: hash-set, conj, concat | |
(defn mergeMatches [propertyMapList] | |
"Take a list of maps and merges them combining values into a set" | |
(reduce #(merge-with FOO %1 %2) {} propertyMapList)) | |
(def in | |
(list | |
{:a 1} |
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 example.ByteInputStream | |
(:gen-class | |
:extends java.io.InputStream | |
:state byteseq | |
:init init | |
:constructors {[clojure.lang.Seqable] []} | |
:exposes-methods {read readSuper} | |
:main false)) | |
(defn -init [byte-seq] |
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
/** | |
Example of using a parameter on a constructor. Parameters on methods are used to | |
describe either type relationships between arguments to the method or between the | |
argument and the return type (more common but not possible in a constructor). Here | |
I use the type X to specify that the two args are of the same type. | |
When calling it, specifying the type is optional as it will automatically be | |
inferred. In cases where the incorrect type is inferred (wrong place in shared | |
hierarchy), you can specify it. If there is no common type, you'll get an error | |
at compile time. |
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 mapmap | |
"Apply kf and vf to a sequence, s, and produce a map of (kf %) to (vf %)." | |
([vf s] | |
(mapmap identity vf s)) | |
([kf vf s] | |
(zipmap (map kf s) | |
(map vf s)))) | |
(defn mapmapmap | |
"Apply kf and vf to the keys and vals of a map and zip the results." |
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
(deftest test-sub= | |
(are [expected left right] (= expected (sub= left right)) | |
;; prim | |
true 1 1 | |
false 1 2 | |
;; maps | |
true {} {:a 1} | |
false {:a 1} {} | |
true {:a 1} {:a 1} | |
false {:a 1} {:a 2} |
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 sub= | |
"Checks that all keys and vals in m1 are in m2 (but m2 can have extra stuff)" | |
[o1 o2] | |
(if (and (map? o1) (map? o2)) | |
(every? identity (map (fn [[k v]] (sub= v (k o2))) o1)) | |
(= o1 o2))) |
OlderNewer