List is a linked list, which is convenient in insertion and deletion, but not perform good in traverse and random indexing. So for a list, modification, appending and conjunction is happened on the top/head of a list.
1 2 3 4
1. '(123) ; (list) are the same 2. (peek '(123)) ;get first element of list; 3. (pop '(123)) ;returns a new list with the first item removed. 4. (conj '(123) 4) ;conjunct last parameter into mid parameter represented list
vector
Vector is like an array, hence perform good in traverse, data appending and random selection, but disappointing in insertion and deletion. So for a vector, modification, append and conjunction is happened on the tail of a vector.
1 2 3 4 5 6 7
1. (vector123) ;convert all elements into a vector 2. (get ["first""second""third"] 1) ;get data of a vector by index, start from 0 3. (peek [123]) ; get data of a list by the tail 4. (conj [123] 45) ; conjunct other parameter into second parameter represented vector 5. (assoc [123] 1"new value") ;return vector that replace target index with last parameter 6. (pop [123]) ;remove the last element of given vector 7. (subvec [12345] start end) ;substract target vector from `start` to `end`
map
very similar to an Object in OOP:
1 2 3 4 5 6 7 8 9 10 11 12
1. (defmy-map {:a1:b2:c3}) ;map definition 2. (my-map:a) ;normal map get 3. (defstructperson:first-name:last-name) ;define struct for frequently used map structure 4. (defperson1 (struct-map person :first-name"Luke":last-name"VanderHart")) ;create instance 5. (defget-first-name (accessor person :first-name)) ;define accessor for performance 6. (get-first-name person1) ;use accessor to access field 7. (assoc {:a1:b2} :c3:d4) ; add or replace indexed element with parameters 8. (dissoc {:a1:b2:c3:d4} :a:c);remove indexed elements with target parameters 9. (merge {:a1:b2} {:c3:d4});merge two maps together 10. (merge-with + {:a1:b2} {:b2:c4});merge maps with operation 11. (keys {:a1:b2:c3}) ;get all keys 12. (vals {:a1:b2:c3}) ;get all values