diff options
author | Rich Hickey <richhickey@gmail.com> | 2007-09-19 21:19:19 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2007-09-19 21:19:19 +0000 |
commit | f745f2189d239572e3247d23384b0d2bc9138c8d (patch) | |
tree | d955403ac947dd4391461aa8af3ffaebba9be25a /clojure.markdown | |
parent | 7aac33d1447ccea5ef6a70318ea67085af994a68 (diff) |
refactoring
Diffstat (limited to 'clojure.markdown')
-rw-r--r-- | clojure.markdown | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clojure.markdown b/clojure.markdown index 2d77b20d..713f02e7 100644 --- a/clojure.markdown +++ b/clojure.markdown @@ -474,6 +474,30 @@ Same as `first`. Returns the first item in the list. If the list is empty, retur --- ### (*pop* list) Returns a new list without the first item. If the list is empty, throws an exception. Note - *not* the same as `rest`. + +### _Vectors (IPersistentVector)_ +Vectors are collections. They are sequences of values indexed by contiguous integers. Vectors support O(log32N) access to items by index. `count` is O(1). `conj` puts the item at the end of the vector. In addition, vectors support the functions: + +--- +### (*vector* & items) +Creates a new vector containing the items. + +--- +### (*assoc* vector index val) +Assoc[iate]. Returns a new vector that contains val at index. Note - index must be <= (count vector). + +--- +### (*get* map index) +### (*nth* map index) +Returns the value at the index. `get` returns `nil` if index out of bounds, `nth` throws an exception. + +--- +### (*peek* vector) +Returns the last item in the vector. If the vector is empty, returns `nil`. + +--- +### (*pop* vector) +Returns a new vector without the last item. If the vector is empty, throws an exception. ### _Maps_ (IPersistentMap) |