I hereby claim:
- I am smee on github.
- I am steffen (https://keybase.io/steffen) on keybase.
- I have a public key whose fingerprint is 27AC ABAE F19D 5432 556D D2F2 6A09 5F97 851C 9D55
To claim this, I am signing this object:
(defn js->clj | |
"Recursively transforms JavaScript arrays into ClojureScript | |
vectors, and JavaScript objects into ClojureScript maps. With | |
option ':keywordize-keys true' will convert object fields from | |
strings to keywords." | |
([x] (js->clj x :keywordize-keys false)) | |
([x & opts] | |
(let [{:keys [keywordize-keys]} opts | |
keyfn (if keywordize-keys keyword str) | |
f (fn thisfn [x] |
(ns multicompare) | |
;;; FIXME the ~key-fn expansion does not resolve all the symbols in `key-fn`, so advanced compilation in clojurescript fails! | |
(defn- multi-compare* [a b [[key-fn order] & key-fn-order-pairs]] | |
(let [c (gensym "compare-result-") | |
k (gensym "key-fn-") | |
compare-clause `(compare ~@(if (#{:asc :ASC :ascending :ASCENDING} order) | |
`[(~k ~a) (~k ~b)] | |
`[(~k ~b) (~k ~a)]))] | |
(if (nil? key-fn-order-pairs) |
(ns diamond-square | |
(:require [clojure.string :as str])) | |
(defn average-of-coords | |
"Calculate the average of a number of cells in a 2D doubles array. | |
Wraps around if coordinates are out of bounds." | |
[^"[[D" arr coords] | |
(let [|arr| (dec (alength arr)) | |
;; use modulo to make the grid tiling | |
coords (map (fn [[i j]] [(mod i |arr|) (mod j |arr|)]) coords)] |
I hereby claim:
To claim this, I am signing this object:
[ Launch: color scale tests ] 9344752 by smee
(fn [coll] (reduce (fn [l c] (map + c (map (partial min) (partition 2 1 l)))) (reverse coll))) | |
problem 132 (oome) | |
(fn [pred sep coll] | |
(flatten | |
(for [[a b] (partition 2 1 (concat coll [(last coll)]))] | |
(if (pred a b) [a sep] a)))) |
(defn wheel-of-fortune [weights] | |
(let [sum (reduce + weights) | |
scaled (cons 0 (reductions + (map #(/ % sum) weights))) | |
intervals (indexed (partition 2 1 scaled)) | |
in-interval? (fn [[l r] val] (and (<= l val) (>= r val)))] | |
(fn [] (let [rnd-val (rand 1)] | |
(some #(when (in-interval? (second %) rnd-val) (first %)) intervals))) | |
)) | |