Skip to content

Instantly share code, notes, and snippets.

@pyrtsa
Created April 8, 2014 10:23
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 pyrtsa/10107433 to your computer and use it in GitHub Desktop.
Save pyrtsa/10107433 to your computer and use it in GitHub Desktop.
Seqables are odd in Clojure. Some functions auto-`seq`, some don't.
(empty? (d/datoms db :aevt :user/id))
;;=> false
(not-empty (d/datoms db :aevt :user/id))
;;=> #<db$datoms$reify__3265 datomic.db$datoms$reify__3265@7939b07>
(seq (d/datoms db :aevt :user/id))
;;=> (#Datum{:e 17592186046081 :a 70 :v "abc" :tx 13194139534976 :added true} ...)
(first (d/datoms db :aevt :user/id))
;;=> #Datum{:e 17592186046081 :a 70 :v "abc" :tx 13194139534976 :added true}
(rest (d/datoms db :aevt :user/id))
;;=> (#Datum{:e 532163627844696 :a 70 :v "def" :tx 13194139534423 :added true} ...)
(list* (d/datoms db :aevt :user/id))
;;=> (#Datum{:e 17592186046081 :a 70 :v "abc" :tx 13194139534976 :added true} ...)
(map :e (d/datoms db :aevt :user/id))
;;=> (17592186046081 532163627844696 ...)
(count (d/datoms db :aevt :user/id)) ;; WTF?
;; UnsupportedOperationException count not supported on this type:
;; db$datoms$reify__3265 clojure.lang.RT.countFrom (RT.java:556)
(vec (d/datoms db :aevt :user/id)) ;; WTF?
;; RuntimeException Unable to convert: class datomic.db$datoms$reify__3265
;; to Object[] clojure.lang.Util.runtimeException (Util.java:219)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment