[] vector

syntaxsince v0.0-1853 in clojure in ednEdit

A vector is the most commonly used form for creating literal sequences.

  • [...]
  • [1 2 3]

Vectors also serve an important language role to prevent you from interpreting sequences as function calls. Whether it's for literal data or for binding forms inside let and fn, vectors provide an important syntax cue not found in other Lisps.


Details:

Elements are inserted at the end via conj, and can be looked up via index. See PersistentVector for data structure details.

Vectors are the conventional form for representing binding forms, that is, when local names are created and bound to values. Examples:


Examples:

[1 2 3]
;;=> [1 2 3]

See Also:


Reader code @ tools.reader:src/main/clojure/clojure/tools/reader.clj
(defn- read-vector
  [rdr _ opts pending-forms]
  (let [[start-line start-column] (starting-line-col-info rdr)
        the-vector (read-delimited :vector \] rdr opts pending-forms)
        [end-line end-column] (ending-line-col-info rdr)]
    (with-meta the-vector
      (when start-line
        (merge
         (when-let [file (get-file-name rdr)]
           {:file file})
         {:line start-line
          :column start-column
          :end-line end-line
          :end-column end-column})))))

Reader table @ tools.reader:src/main/clojure/clojure/tools/reader.clj
(defn- macros [ch]
  (case ch
    \" read-string*
    \: read-keyword
    \; read-comment
    \' (wrapping-reader 'quote)
    \@ (wrapping-reader 'clojure.core/deref)
    \^ read-meta
    \` read-syntax-quote ;;(wrapping-reader 'syntax-quote)
    \~ read-unquote
    \( read-list
    \) read-unmatched-delimiter
    \[ read-vector
    \] read-unmatched-delimiter
    \{ read-map
    \} read-unmatched-delimiter
    \\ read-char*
    \% read-arg
    \# read-dispatch
    nil))