1.3.0 permalink Arrow_down_16x16
  • (seq coll)
Returns a seq on the collection. If the collection is
empty, returns nil. (seq nil) returns nil. seq also works on
Strings, native Java arrays (of reference types) and any objects
that implement Iterable.

3 Examples top

  • user=> (seq '())
    nil
    
    user=> (seq '(1))
    (1)
    
    user=> (seq "")
    nil
    
    user=> (seq "abc")
    (\a \b \c)
    
  • ;(seq x) is the recommended idiom for testing if a collection is not empty
    user=> (every? seq ["1" [1] '(1) {:1 1} #{1}])
    true
  • ; seq can be used to turn a map into a list of vectors
    ; notice how the list is built adding elements to the start of the list
    ; not to the end, like in vectors
    user=> (seq {:key1 "value1" :key2 "value2"})
    ([:key2 "value 2"] [:key1 "value 1"])
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:124 top

(def
 ^{:arglists '(^clojure.lang.ISeq [coll])
   :doc "Returns a seq on the collection. If the collection is
    empty, returns nil.  (seq nil) returns nil. seq also works on
    Strings, native Java arrays (of reference types) and any objects
    that implement Iterable."
   :tag clojure.lang.ISeq
   :added "1.0"
   :static true}
 seq (fn ^:static seq ^clojure.lang.ISeq [coll] (. clojure.lang.RT (seq coll))))
Vars in clojure.core/seq:
Used in 0 other vars

Comments top

No comments for seq. Log in to add a comment.