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 time-it | |
"Signature slightly awkward to resemble that of time-it-mac" | |
([f] (time-it f 1)) | |
([n f] | |
(. clojure.lang.RT (StartStopwatch)) | |
(dotimes [_ n] (f)) | |
(let [t (. clojure.lang.RT StopStopwatch)] | |
(/ t n)))) | |
(defmacro time-it-mac |
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 invocation-cost) | |
(defn time-it | |
"Signature slightly awkward to resemble that of time-it-mac" | |
([f] (time-it f 1)) | |
([n f] | |
(. clojure.lang.RT (StartStopwatch)) | |
(dotimes [_ n] (f)) | |
(let [t (. clojure.lang.RT StopStopwatch)] | |
(/ t n)))) |
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 madness) | |
(defn reset [] | |
((fn clesgo [n] | |
(defn go-clesgo [m] | |
(clesgo (+ n m))) | |
n) | |
1)) | |
(defn abandon-hope [] |
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
invocation-cost=> (time-it-mac 1e6 ((fn [x] x) :hi)) | |
0.012968 | |
invocation-cost=> (let [f (fn [x] x)] | |
(time-it-mac 1e6 (f :hi))) | |
1.1E-05 |
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 unchecked-on [] | |
(alter-var-root #'*unchecked-math* (constantly true))) | |
(defn unchecked-off [] | |
(alter-var-root #'*unchecked-math* (constantly false))) |
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
(defmacro array-mac [t & elements] | |
(let [^Type tt (resolve t) | |
atypesym (symbol (str (.FullName tt) "[]")) | |
asym (gensym "array_") | |
setexprs (->> elements | |
(map-indexed | |
(fn [i x] | |
`(aset ~asym ~i ~x))))] | |
`(let [~(with-meta asym {:tag atypesym}) (make-array ~t ~(count elements))] | |
~@setexprs |
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
(binding [*data-readers* {'v3 (fn [[x y z]] (UnityEngine.Vector3. x y z))}] | |
(eval (read-string "#v3[1 2 3]"))) | |
;; => (1.0, 2.0, 3.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
(defmacro condcast-> [expr xsym & clauses] | |
(let [exprsym (gensym "exprsym_") | |
[clauses default] (if (even? (count clauses)) | |
[clauses nil] | |
[(butlast clauses) | |
[:else | |
`(let [~xsym ~exprsym] | |
~(last clauses))]]) | |
cs (->> clauses | |
(partition 2) |
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
using clojure.lang; | |
using System; | |
using UnityEngine; | |
namespace urbanOutfitters.moholy | |
{ | |
[Serializable] // really? | |
public class axis_angle : AFunction | |
{ | |
// | |
// Static Fields |
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 fuzzy-finder-fn [name-fn resource-fn] | |
(fn [string-or-regex] | |
(let [f (if (instance? System.Text.RegularExpressions.Regex string-or-regex) | |
#(re-find string-or-regex (name-fn %)) | |
(let [^String s string-or-regex] | |
#(let [^String n (name-fn %)] | |
(.Contains n s))))] | |
(filter f (resource-fn))))) | |
;; example: |