You're viewing version 1.2.0 of seq. The latest stable version of Clojure Core is 1.3.0.
1.2.0 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 '())
    user=> (seq '(1))
    user=> (seq "")
    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}])
  • ; 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:114 top

 ^{:arglists '([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"}
 seq (fn seq [coll] (. clojure.lang.RT (seq coll))))
Vars in clojure.core/seq: fn
Used in 448 other vars (expand)
list* booleans longs shorts bound-fn dorun time doseq if-not some letfn for dosync with-open sync let dotimes defmethod lazy-cat defstruct with-in-str loop import sequence into-array defrecord with-out-str floats butlast ->> refer-clojure .. with-loading-context future xml-seq doubles doto rsubseq proxy-super assert memfn chars when-first definline pvalues ns empty? with-precision or condp file-seq with-local-vars with-bindings set when-let amap -> cons while bean case ints deftype supers bytes if-let and declare locking definterface delay apply defmulti proxy reify defonce io! areduce not-empty flatten every? sort binding doc subseq emit-array-impls with-sh-dir with-sh-env with-bindings formatter-out formatter pp with-pprint-dispatch pprint-logical-block source dir join do-template deftest- assert-predicate deftest is testing try-expr assert-any are with-test-out set-test with-test start-element with-junit-output with-tap-output lefts vector-zip leftmost xml-zip left deftype capture-and-send with-command-line cond-let raise handler-case defn-memo defhinted defalias defnk dissoc-in cell ?- <- map-values trace-datalog build-atom with-in-reader with-out-append-writer with-out-writer deferror throw-msg continue continue-with with-handler do-not-handle raise re-case case in-case instance-case -seq source run defadt defmethod* seq import-static with-in-reader with-out-append-writer with-out-writer with-system-properties invoke with-connection formatter-out info log trace error spy with-logs warn enabled? debug fatal macrolet deftemplate defsymbolmacro with-symbol-macros symbol-macrolet with-direct-linking letfn- lazy-get vars times dir has-args expect docs with-monad domonad defmonad m-when-not m-when monad monad-transformer defmonadfn formatter prlabel pp with-pprint-dispatch pprint-binding-form pprint-logical-block discrete defstream with-profile-data profile prof with-system-properties rec-seq rec-cat shuffle reductions rotations flatten rec-seq rec-cat shuffle reductions rotations flatten with-sh-dir with-sh-env with-sh-dir with-sh-env with-query-results transaction with-connection do-commands do-prepared re-split split split-lines docodepoints dochars deftype- defst st-as-stream split split-lines docodepoints dochars << do-swing do-swing-and-wait deftest- do-template assert-predicate deftest is testing find-symbols try-expr assert-any are find-pure-exprs with-test-out set-test with-test template? dotrace deftrace match with-ns with-temp-ns seq-test defservice time-series-plot get-series box-plot add-box-plot add-categories stacked-bar-chart bar-chart quantile heat-map xy-plot pie-chart scatter-plot dynamic-scatter-plot line-chart function-plot add-points histogram sliders add-function add-lines stacked-area-chart area-chart dynamic-xy-plot add-histogram to-vect combine-with diag $fn bind-rows with-data transform-with with-rotation sketch with-translation deriv-fn deriv reset define-ant-task has-run? define-ant-type deftarget define-all-ant-tasks task-names deps compile defproject repl-server form-for-testing-namespaces describe testing-fn for-these it should colorize defconfig describe expand-subcontext-forms defn! times has-args expect fail for-these collection-generator char-generator for-all generator testing-fn it with-timing rewrite-=> debug-repl pop-optional-args local-bindings should given and when then wtf with-re-defn run-watcher local-bindings eval-with-locals strict-mode transform-content deftemplate snippet* defsnippets template defsnippet transformation at clone-for sniptest let-select snippet lockstep-transformation xml-zip swank macroexpand-all* defslimefn eval-for-emacs with-emacs-package send-repl-results-to-emacs sldb-loop dothread-keeping-clj break source-location-for-frame position with-env-locals failing-gracefully continuously find-definitions-for-emacs dothread-keeping one-of? connection-info local-bindings returning keep-bindings compile-string-for-emacs dothread dothread-swank dispatch-event with-package-tracking with-timeout defhook with-connection inspect-meta-information label-value-line* with-swank-io start-repl call-being-tested expect fake with-default-identity memfn-varargs with-connection when-feature with-default-session-options with-ssh-agent defcontract with-constraints defconstrainedfn new-sandbox-compiler s-seq toggle-button button-group radio-button radio-button-menu-item auto-setters general-button add-action-listener button icon-setters check-box check-box-menu-item has-index? insert-at combo-box add-listener drop-nth string-ref-content label split-vertical shelf set-constraint! general-panel split-horizontal jlist stack text-field frame list-model tree panel scroll-panel add-list-selection-listener combinations expect has-args times contract provide-contracts

Comments top

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