Created
April 8, 2014 10:23
-
-
Save pyrtsa/10107433 to your computer and use it in GitHub Desktop.
Seqables are odd in Clojure. Some functions auto-`seq`, some don't.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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