Created
August 27, 2024 16:06
-
-
Save dvliman/9ae80ebbba797fde22e0f1915ce9f93c to your computer and use it in GitHub Desktop.
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
(def log-store (atom {})) | |
(defn debug [tag val] | |
(swap! log-store update-in [tag] #(conj (or % []) val)) | |
val) | |
(defn logs | |
[tag & functions] | |
(let [tag (if (number? tag) | |
(nth (keys @log-store) tag) | |
tag)] | |
(loop [values (@log-store tag) | |
functions functions] | |
(if (seq functions) | |
(recur ((first functions) values) | |
(rest functions)) | |
values)))) | |
(defn same-values? [x] | |
(if (= 1 (count (set x))) | |
:same-values | |
:different-values)) | |
(defn tags [] | |
(->> @log-store | |
(reduce-kv #(assoc %1 [(count %3) (same-values? %3) %2] (last %3)) {}) | |
(map-indexed hash-map) | |
(into []))) | |
(defn debug-data-reader [form] | |
`(debug (quote ~form) ~form)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment