Skip to content

Instantly share code, notes, and snippets.

@yurrriq
Created April 7, 2015 08:07
Show Gist options
  • Select an option

  • Save yurrriq/b0dc479fe3adcda7e0d2 to your computer and use it in GitHub Desktop.

Select an option

Save yurrriq/b0dc479fe3adcda7e0d2 to your computer and use it in GitHub Desktop.
empty.clj
;; I forget about this function too often, so now it's a gist!
(empty '(1 2 3)) ; <= ()
(type *1) ; <= clojure.lang.PersistentList$EmptyList
(empty (range 1 3)) ; <= ()
(type *1) ; <= clojure.lang.PersistentList$EmptyList
(empty [1 2 3]) ; <= []
(type *1) ; <= clojure.lang.PersistentVector
(empty {:abc 123}) ; <= {}
(type *1) ; <= clojure.lang.PersistentArrayMap
(empty (sorted-map :a 1)) ; <= {}
(type *1) ; <= clojure.lang.PersistentTreeMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment