Created
August 27, 2024 16:06
-
-
Save dvliman/9ae80ebbba797fde22e0f1915ce9f93c to your computer and use it in GitHub Desktop.
Revisions
-
dvliman created this gist
Aug 27, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ (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))