This task is about arrays.

For hashes or associative arrays, please see Creating an Associative Array.

For a definition and in-depth discussion of what an array is, see Array.



Task

Show basic array syntax in your language.

Basically, create an array, assign a value to it, and retrieve an element   (if available, show both fixed-length arrays and
dynamic arrays, pushing a value into it).

Please discuss at Village Pump:   Arrays.

Please merge code in from these obsolete tasks:

   Creating an Array
   Assigning Values to an Array
   Retrieving an Element of an Array


Related tasks

   Collections
   Creating an Associative Array
   Two-dimensional array (runtime)


;clojure is a language built with immutable/persistent data structures. there is no concept of changing what a vector/list 
;is, instead clojure creates a new array with an added value using (conj...)
;in the example below the my-list does not change.
 
 
user=> (def my-list (list 1 2 3 4 5))
 
user=> my-list
(1 2 3 4 5)
 
user=> (first my-list)
1
 
user=> (nth my-list 3)
4
 
user=> (conj my-list 100) ;adding to a list always adds to the head of the list
(100 1 2 3 4 5)
 
user=> my-list ;it is impossible to change the list pointed to by my-list
(1 2 3 4 5)
 
user=> (def my-new-list (conj my-list 100))
 
user=> my-new-list
(100 1 2 3 4 5)
 
user=> (cons 200 my-new-list) ;(cons makes a new list, (conj will make a new object of the same type as the one it is given
(200 100 1 2 3 4 5)
 
user=> (def my-vec [1 2 3 4 5 6])
 
user=> (conj my-vec 300) ;adding to a vector always adds to the end of the vector
[1 2 3 4 5 6 300]