ClojureBridge/curriculum

Reword initial description of vectors

Closed this issue · 4 comments

At the beginning of the "Vectors" section of data_structures.md, there's an initial description of vectors:

Vectors are sequential collections of data. You could say they are lists of data, but we also have another collection called a list. If you have programmed in another language, these might have been called arrays in that language.

...this needs rephrasing. Suggestions?

Perhaps something like this?

A vector is a sequential collection of values. A vector may be empty. A vector may contain values of different types. A vector's values are indexed by numbers starting from 0: the first value lies at index 0, the second at index 1, the third at index 2, and so on.

I think we should avoid mentioning the list type at this point.

I agree that mentioning the list type is confusing here. I like @davidchambers' proposal. I wonder if there's a simpler way to express the idea of what it means for a value to be indexed by a number. Maybe saying something like "Each value in a vector is numbered starting at 0, that number is called its index. The index is used to refer to each value when looking them up." I'm thinking that the word will be new to some people.

We could also mention that vectors can have the same value more than once.

Each value in a vector is numbered starting at 0, that number is called its index. The index is used to refer to each value when looking them up.

I like this.

Updated, http://clojurebridge.github.io/curriculum/outline/data_structures.html#/2 , with this phrase:

A vector is a sequential collection of values. A vector may be
empty. A vector may contain values of different types.
Each value in a vector is numbered starting at 0, that number is
called its index. The index is used to refer to each value when
looking them up.