Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Last active April 8, 2018 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfredericks/c1cb1eb415241c106ab54d9cf9aea5de to your computer and use it in GitHub Desktop.
Save gfredericks/c1cb1eb415241c106ab54d9cf9aea5de to your computer and use it in GitHub Desktop.
A clojure.spec quine
(s/def ::quine
((fn [x]
(s/cat :the-def #{'s/def}
:the-quine #{::quine}
:the-spec (s/spec
(s/cat :x #{x}
:x' (s/spec
(s/cat :quote #{'quote}
:x #{x}))))))
'(fn [x]
(s/cat :the-def #{'s/def}
:the-quine #{::quine}
:the-spec (s/spec
(s/cat :x #{x}
:x' (s/spec
(s/cat :quote #{'quote}
:x #{x}))))))))
(s/valid? ::quine
'(s/def ::quine
((fn [x]
(s/cat :the-def #{'s/def}
:the-quine #{::quine}
:the-spec (s/spec
(s/cat :x #{x}
:x' (s/spec
(s/cat :quote #{'quote}
:x #{x}))))))
'(fn [x]
(s/cat :the-def #{'s/def}
:the-quine #{::quine}
:the-spec (s/spec
(s/cat :x #{x}
:x' (s/spec
(s/cat :quote #{'quote}
:x #{x})))))))))
;; => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment