Массивы и коллекции / Массивы

(def primes [2 5 7])
(println primes)                                ; [2 5 7]

;; a vector is persistent: nothing is changed in place,
;; every operation returns a NEW vector
(def more (conj primes 11))                     ; append to the end
(println more)                                  ; [2 5 7 11]
(println primes)                                ; [2 5 7] — the original is intact

(def with-3 (into [2 3(subvec more 1)))       ; insert 3 at index 1
(println with-3)                                ; [2 3 5 7 11]

(def tail (subvec with-3 1))                    ; drop the element at index 0
(println tail)                                  ; [3 5 7 11]

(println (into tail [13 17]))                   ; [3 5 7 11 13 17] — extend
(println (vec (remove #{7} tail)))              ; [3 5 11] — remove by value
(println (empty tail))                          ; [] — "clear" is just an empty vector