I recently listened to Rich Hickey\'s interview on Software Engineering Radio. During the interview Rich mentioned that Clojure\'s collections are implemented as trees. I\'m
You should really read Clojure Programming, it covers this in great detail, including pictures. Briefly though, collections are depth first searches through trees. We can show your examples like this:
(def x #{1 2 3})
x
|
| \
|\ 3
1 \
2
(def y (conj x 4))
x y
| / \
| \ 4
|\ 3
1 \
2
(def z (difference y #{1}))
x y
| / \
| \ 4
|\ 3
1/\
z- 2
Note that these are just indicative, I'm not saying that this is exactly the layout Clojure uses internally. It's the gist though.