Skip to content

Instantly share code, notes, and snippets.

@gdanov
Last active May 29, 2016 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdanov/3f58760866108a412fed570210c25330 to your computer and use it in GitHub Desktop.
Save gdanov/3f58760866108a412fed570210c25330 to your computer and use it in GitHub Desktop.
(defmacro eq [x]
`(sp/&
(fn [v#]
(println "#~" v#)
(= v# ~x))
(sp/conformer #(do (println "#" %) %))))
;; twice
(sp/conform (sp/cat :a (eq :a)) [:a])
;; 3 times
(sp/conform (sp/cat :a (sp/alt :a-a (eq :a))) [:a])
;; 4 times
(sp/conform (sp/cat :a (sp/alt :a-a (sp/alt :a-a-a (eq :a)))) [:a])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment