Skip to content

Instantly share code, notes, and snippets.

@joinr
Created September 24, 2019 21:06
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 joinr/bed4cb86a7590abd4519417b426f6ad7 to your computer and use it in GitHub Desktop.
Save joinr/bed4cb86a7590abd4519417b426f6ad7 to your computer and use it in GitHub Desktop.
a demonstration of how trivial it is to splice things in clojure
`[~(range 10) ~[:this :vector :is] ~{:brought "to" :you "by"} ~@[:splicing :vectors]
~#{:sets} :and ~@'(:lists :together) :somewhat :trivially
~@{:even {:nested [:vectors]} :and [:maps :of :stuff] :are :easy} #{~@[:so :are :sets]}
~(eval `[:its :even [:easy ~@[:to :splice :quoted :forms]
~{:of :varying :levels #{:of-depth}}]])]
;;yields
[(0 1 2 3 4 5 6 7 8 9)
[:this :vector :is]
{:brought "to", :you "by"}
:splicing
:vectors
#{:sets}
:and
:lists
:together
:somewhat
:trivially
[:even {:nested [:vectors]}]
[:and [:maps :of :stuff]]
[:are :easy]
#{:so :are :sets}
[:its
:even
[:easy :to :splice :quoted :forms {:of :varying, :levels #{:of-depth}}]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment