Skip to content

"Vectors and lists" - wording in tutorial #33

Description

@mindplay-dk

At one point in the tutorial, it states "Vectors and lists are sequential and ordered collections" - but the preceding example does not show anything called "lists", just vectors, maps and sets.

Maybe vectors and lists are the same thing? I don't know Clojure yet.

Activity

  1. harshadsabne commented on Sep 6, 2013

    @harshadsabne

    @mindplay-dk : Following examples already nicely explained in the tutorial by @Raynes 👍 are lists:

    (+ 3 3) // A list containing an operator and then operands.
    (/ 10 3) // A list containing an operator and then operands.
    (defn square [x] (* x x) ) //A "square" function that takes a single number and squares it. This entire defn block is a list. Here [x] is a vector while (* x x) is a list.

    Coming back to your question:

    1. NO, Vectors and Lists are not the same.
    2. Both "Vectos" and "Lists" belong to Clojure "Collections" and all Clojure collections are immutable and persistent.

    About Lists:

    1. Lists are used for sequential processing of data items.
    2. Lists are linked-list data structures.
    3. (class '(1 2 3)); => clojure.lang.PersistentList

    About Vectors:

    1. Vectos are indexed by contiguous integers, meaning you can access vector items by index.
    2. Vectors are array based.
    3. (class [1 2 3]); => clojure.lang.PersistentVector

    Hope this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions