At this juncture, I noticed an interesting pattern with the behaviour of conj
in Clojure.
As per ClojureDocs:
;; notice that conjoining to a vector is done at the end
(conj [1 2 3] 4)
;;=> [1 2 3 4]
;; notice conjoining to a list is done at the beginning
(conj '(1 2 3) 4)
;;=> (4 1 2 3)
Why? According to a Perplexity AI answer and my PromptBros agent, it is because:
Vectors are arrays, and the convenient place is for items to be added at the end.
Lists are linked lists, and the the convenient place is for items to be added is at the beginning.
Not sure if this is accurate, but if so, it is a really cool way of signalling the difference!