Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does (= (vector nil) (vec nil)) return false?

Is this just a quirk, or is there some fundamental concept that implies this?

like image 727
Johnny Brown Avatar asked Feb 13 '11 21:02

Johnny Brown


2 Answers

vec converts into a vector(nil becomes an empty vector) while vector creates a vector with the given elements.

(vec nil) => []
(vector nil) => [nil]

you could have entered these expressions into a repl to see their results and why they're not equal.

like image 63
DaVinci Avatar answered Nov 14 '22 04:11

DaVinci


user> (vec nil) ; => []

user> (vector nil) ; => [nil]

user> (= *1 *2) ; => false

Why should these be equal?

like image 24
MayDaniel Avatar answered Nov 14 '22 04:11

MayDaniel