In clojure, you have several functions that act differently for a vector and for a list. I have two questions.
1) What is it useful for? I believe that the creator of clojure has a very good reason for this, but I do not know.
2) How can you make a typical version of these functions that will act the same way, regardless of whether the data is in a list or a vector?
The conj function, as defined, has the following behavior
(conj [1 2 3] 4) [1 2 3 4] (conj '(1 2 3) 4) (4 1 2 3)
I would like to have a my-conj function with the following behavior
(my-conj [1 2 3] 4) [1 2 3 4] (my-conj '(1 2 3) 4) (1 2 3 4)
There is another function (cons, to, peek, pop) with the same behavior, so it would be nice if this design could easily adapt to all of them.
source share