Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Created March 12, 2026 10:56
Show Gist options
  • Select an option

  • Save sogaiu/ee18a6b9b1dbfa548d6b61b6496966b7 to your computer and use it in GitHub Desktop.

Select an option

Save sogaiu/ee18a6b9b1dbfa548d6b61b6496966b7 to your computer and use it in GitHub Desktop.
macro hygiene stuff
(defmacro each-reverse [identifier list & body]
  (with-syms [$i $list]
    ~(let [,$list ,list]
      (var ,$i (,dec (,length ,$list)))
      (while (>= ,$i 0)
        (def ,identifier (in ,$list ,$i))
        ,;body
        (-- ,$i)))))
(defmacro each-reverse [identifier list & body]
  (with-syms [$i $list]
    ~(as-macro ,let [,$list ,list]
      (var ,$i (,dec (,length ,$list)))
      (while (,>= ,$i 0)
        (def ,identifier (,in ,$list ,$i))
        ,;body
        (as-macro ,-- ,$i)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment