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 hendekagon.docker | |
" | |
Docker admin | |
adapted from | |
https://github.com/lispyclouds/contajners/blob/main/doc/002-general-guidelines.md | |
" | |
(:require | |
[clojure.string :as string] | |
[clojure.java.io :as io] |
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
(require '[clojure.core.matrix :as m]) | |
(defn mup [mat rs cs f] | |
(m/set-selection mat rs cs | |
(f (m/select mat rs cs)))) | |
(defn qr | |
" | |
QR decomposition by Householder reflection | |
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
(require '[criterium.core :as c]) | |
(defprotocol W (w [this x y])) | |
(def w1 (reify W (w [t x y] (* x y)))) | |
(c/quick-bench (w w1 4 4)) | |
; protocol dispatch | |
; Execution time mean : 6.625560 ns |
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
(let [{z :x x 'y y "z" :keys [x y z] :syms [x y z] :strs [x y z]} {:x 1 'y 2 "z" 3}] [x y z]) | |
=> [nil nil 3] | |
(let [{z :x x 'y y "z" :keys [x y z] :syms [x y z]} {:x 1 'y 2 "z" 3}] [x y z]) | |
=> [nil 2 nil] | |
(let [{z :x x 'y y "z" :keys [x y z]} {:x 1 'y 2 "z" 3}] [x y z]) | |
=> [1 nil nil] | |
(let [{z :x x 'y y "z"} {:x 1 'y 2 "z" 3}] [x y 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
; https://www.scientificamerican.com/article/is-inequality-inevitable/ | |
; https://threadreaderapp.com/thread/1210332075787608065.html | |
(defn economy-dw | |
" | |
Simulate one round of | |
random transfers of wealth | |
between the given agents' accounts | |
(a vector of initial amounts) |
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 mms | |
(:require | |
[clojure.math.combinatorics :as x] | |
[clojure.set :as set])) | |
(defn derive-set | |
" | |
A copy of derive for sets | |
" | |
([h a-set parent-set] |
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
; I was curious as to whether unrolling | |
; this use of transducers would be faster | |
; | |
; in fact it's slower | |
; we're given an array which we | |
; process using fns f, g and h | |
(defn test1-xf [^bytes data] | |
(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
(fn [params] | |
{ | |
:namespace-name 'a | |
:requires [] | |
:defs | |
'{ | |
x (fn [y] (str "a's " y)) | |
}}) |
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 put [f x] (let [is-str? (char? (first x)) sx (apply str x)] (cond (map? f) (into {} (map vec (partition 2 (if (even? (count x)) x (conj x nil))))) (vector? f) (if is-str? (conj f sx) (into f x)) (list? f) (if is-str? (cons sx f) (concat f x)) (set? f) (if is-str? #{sx} (into f x))))) | |
(defn structure [s f] (mapv (fn [b a] (if (empty? b) (put b a) (let [r (structure a b)] (if (vector? b) (vec r) r)))) f (partition-all (int (/ (count s) (count f))) s))) | |
(structure (range 32) [[[] #{}] [#{} [] []]]) | |
=> | |
[[[0 1 2 3 4 5 6 7] #{15 13 12 11 9 14 10 8}] |
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
(let [eval-right? clojure.core/eval] (intern 'clojure.core 'eval (fn [form] (if (= 'right? (last form)) (eval-right? (butlast form)) 'right?)))) |
NewerOlder