Last active
August 8, 2023 20:02
-
-
Save adamdavislee/4fd2c07944e113bd030b2a3468b98c48 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
;; Custom inspection tool! | |
;; ======================= | |
(defn appendv | |
[coll & args] | |
(apply conj (vec coll) args)) | |
(def *inspections* (atom {})) | |
(defmacro inspect | |
[tag] | |
(let [env# (->> &env (keys) (mapv (juxt str identity)) (into {}))] | |
`(swap! *inspections* update ~tag appendv ~env#))) | |
(defmacro for-inspect | |
[tag & forms] | |
(vec (map-indexed (fn [index runs] | |
`(let ~(vec (mapcat | |
(fn [[k _v]] [`~(symbol k) `(get-in @*inspections* ~[tag index k])]) | |
runs)) | |
~@forms)) | |
(take-last 12 (@*inspections* tag))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment