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
dir defmulti defprotocol Type | |
..\spork 27 170 proto-dominant | |
..\tech.datatype 21 60 proto-dominant | |
..\clojure 28 35 proto-dominant | |
..\faster-multimethods 60 0 multi-dominant | |
..\dtype-next 2 32 proto-dominant | |
..\incanter 23 5 multi-dominant | |
..\clojure2d-examples 0 27 proto-dominant | |
..\fastmath 15 11 multi-dominant | |
..\penumbra 11 13 proto-dominant |
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
;;discussed at https://clojurians.zulipchat.com/#narrow/stream/151168-clojure/topic/rule.20based.20data.20manipulation/near/234283215 | |
(ns logos.core | |
(:require [clojure.core.logic :refer :all :as l])) | |
(defn resolve-rule [ctx k] | |
(loop [res (ctx k)] | |
(if (and (keyword? res) | |
(contains? ctx res)) | |
(recur (ctx res)) | |
res))) |
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
{:deps {overload-fn/overload-fn {:mvn/version "0.1.0"} | |
fastmeth/fastmeth {:mvn/version "0.1.0-SNAPSHOT"} | |
criterium/criterium {:mvn/version "0.4.6"}} | |
:aliaes {;; See https://github.com/cognitect-labs/REBL-distro/wiki/REBL-and-nREPL | |
:nREPL {:extra-deps {nrepl/nrepl {:mvn/version "0.6.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
(ns aoc2020.demo) | |
(def demo [3 8 9 1 2 5 4 6 7]) | |
;;transcribed from https://www.youtube.com/watch?v=5AqX3Wu00ok | |
(defn cups->circle ^longs [cups-prefix ^long total-cups] | |
(let [circle (long-array (inc total-cups))] | |
(doseq [[a b] (partition 2 1 cups-prefix)] | |
(aset-long circle 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
(require '[criterium.core :as c]) | |
(c/quick-bench | |
(reduce (fn [acc k] (assoc acc k k)) {} (range 10000))) | |
;;Execution time mean : 1.682198 ms | |
(c/quick-bench | |
(persistent! | |
(reduce (fn [acc k] (assoc! acc k k)) (transient {}) (range 10000)))) |
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
AC-Supply RC-Supply Total color | |
0 1 0.045520739 0 | |
0 2 0.071107953 0 | |
0 3 0.150327472 0 | |
0 4 0.192504721 0 | |
0 5 0.221096196 0 | |
0 6 0.267587869 0 | |
0 7 0.319542007 0 | |
0 8 0.366750742 0 | |
0 9 0.367490051 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
(ns rrbtest.core | |
(:require [criterium.core :as c] | |
[clojure.core.rrb-vector :as fv])) | |
(let [v (vec (range 1000000))] | |
(c/quick-bench (reduce (fn [_ _] nil) nil v))) | |
;; Evaluation count : 72 in 6 samples of 12 calls. | |
;; Execution time mean : 8.588929 ms | |
;; Execution time std-deviation : 158.450269 µ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
;;These mods pulled runtime down about 37x without going into primitive arrays, | |
;;and retaining a good bit of the original code. | |
;;Intermediate mods that got us down about 12x, keeping fairly clost to the original. | |
#_(defn split-adjacent [f xs] | |
(let [prev (atom nil) | |
res (reduce (fn [acc x] | |
(if (f x) | |
(reset! prev x) |
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 pizza | |
(:require [clojure.spec.alpha :as s])) | |
(s/def :order/id int?) | |
(s/def :order/status #{:received :delivered :cancelled}) | |
(s/def :pizza/kind #{:plain :pepperoni :hawaiian}) | |
(s/def ::pizza-order (s/keys :req [:order/id :order/status :pizza/kind])) | |
;;pack some "type" into the data | |
(def my-pizza-order |
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
;;added libpython-clj.python.logging require to libpython-clj.jna.base | |
(defmacro def-pylib-fn | |
[fn-name docstring rettype & argpairs] | |
`(defn ~fn-name | |
~docstring | |
~(mapv first argpairs) | |
(log-info (str [:skipping-GIL-check! | |
{:name ~fn-name | |
:thread (current-thread-id) | |
:gil-thread (.get ^AtomicLong gil-thread-id)}])) |