;; 向量正是栈:conj 在其末尾添加,
;; peek 读取末尾,pop 移除末尾
(def int-stack (-> [] (conj 1) (conj 3) (conj 5)))
;; int-stack is [1 3 5]
(println "top is" (peek int-stack))
(println "first is" (peek int-stack))
(println "second is" (peek (pop int-stack)))
(println "third is" (peek (pop (pop int-stack))))
;; 栈顶是 5,随后依次得到 5, 3, 1:后进先出
;; 注意:若是列表,同样的 conj/peek/pop 作用的恰恰是开头,而非末尾
(def int-list (-> '() (conj 1) (conj 3) (conj 5)))
;; int-list 是 (5 3 1),所以 peek 同样得到 5
(println "list is" int-list "- top is" (peek int-list))