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
(-> test-results | |
(->> (map #(list (:id %) (:prefill_config %)))) | |
flatten | |
(->> (apply hash-map)) | |
keywordize-keys | |
(select-keys (map keyword current-form-ids))) |
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
// helper fn used by merge_sort; merges two arrays into sorted order | |
var merge = function (left, right) { | |
let merged = [], | |
i = 0, // left array index counter | |
j = 0; // right array index counter | |
while (i < left.length && j < right.length) { | |
if (left[i] < right[j]) { | |
merged.push(left[i]); | |
i++; |
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
// Takes a function, f, and returns a memoized version of f. | |
// Note: only memoize pure, idempotent functions | |
var memoize = function (f) { | |
let store = new Map(); | |
return function (...args) { | |
const k = JSON.stringify(args); | |
return (store.has(k) ? | |
store.get(k) : | |
store.set(k, f(...args)).get(k)); |
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
function stringify(obj, seenStack = []) { | |
if (obj instanceof Array) { | |
return "[" + | |
obj.reduce((acc, v, idx) => { | |
let sanitizedV = v; | |
if (typeof sanitizedV === 'string') { | |
sanitizedV = "\"" + sanitizedV + "\""; | |
} | |
return acc + (idx !== 0 ? "," : "") + stringify(sanitizedV, seenStack); | |
}, "") + |
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
;; http://www.4clojure.com/problem/178 | |
(fn [card-strs] | |
(let [card-str->map (fn [[suit-char rank-char]] | |
{:suit ({\S :spade | |
\H :heart | |
\D :diamond | |
\C :club} suit-char) | |
:rank (case rank-char | |
\A 12 | |
\K 11 |
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 [roman-str] | |
(let [letter-val {\0 0 ;; for padding last tuple | |
\I 1, \V 5, \X 10, \L 50 | |
\C 100, \D 500, \M 1000} | |
letter-tuple->dec (fn [[l r]] | |
(* (letter-val l) | |
(if (< (letter-val l) (letter-val r)) | |
-1 | |
1)))] | |
(->> roman-str |