Skip to content

Instantly share code, notes, and snippets.

@dvliman
Created August 27, 2024 16:06
Show Gist options
  • Save dvliman/9ae80ebbba797fde22e0f1915ce9f93c to your computer and use it in GitHub Desktop.
Save dvliman/9ae80ebbba797fde22e0f1915ce9f93c to your computer and use it in GitHub Desktop.
(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