Building Custom Collections

If none of the Clojure collections are right for your problem, you may need to roll your own. Like the standard collections, custom collections can be used seamlessly with the Clojure core library. Building a custom collection requires the use of deftype to implement the trait interfaces Clojure uses internally.

Collection Traits

If we want to build a collection that Clojure can use, we need to understand more deeply how Clojure interacts with collections. The collection and sequence libraries are based not on the particular implementations included in Clojure but on a generic set of traits that define key abstractions. Clojure collection traits are implemented internally using Java interfaces.

Predicate functions ...

Get Clojure Applied now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.