top | item 13422966

(no title)

inconclusive | 9 years ago

How is the cost of copying close to zero or not apparent?

discuss

order

rads|9 years ago

The data structures in Clojure are built on shallow 32-way trees. When you "change" a map or a vector, the algorithm only copies from the root node down to the parent of the leaf you're changing. That's log32(N) copied nodes in a tree of N nodes total.

macmac|9 years ago

Because persistent data structures that use structural sharing.

DannyB2|9 years ago

Good answers by others. The cost it not quite zero, but very close. The benefits this buys are huge. The obvious case is recursive search algorithms.