>  (rest *v1) is equal to *v2 in the below mentioned example. Then why
>  `conj' operation on them is returning different things.

rest is giving you a seq. conj is thus producing a cons where the  
first is 0 and the rest is that seq. (Essentially, seqs are treated as  
lists, and thus print with parens.)

user=> (rest [1 2 3 4 5])
(2 3 4 5)

user=> (type (rest [1 2 3 4 5]))
clojure.lang.PersistentVector$ChunkedSeq

user=> (conj (rest [1 2 3 4 5]) 1)
(1 2 3 4 5)

user=> (type *1)
clojure.lang.Cons

user=> (rest *2)
(2 3 4 5)

user=> (type *1)
clojure.lang.PersistentVector$ChunkedSeq


If you want conj to act as if it's working on a vector, you need to  
give it a vector:

user=> (conj (vec (rest [1 2 3 4])) :a)
[2 3 4 :a]

user=> (conj (rest [1 2 3 4]) :a)
(:a 2 3 4)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to