Structures
Discover Clojure's core data structures, including immutable collections, numbers, characters, symbols, and keywords. Learn how these structures preserve versions, support efficient hashing, and interact with JVM types. Understand key functions for manipulating collections and their unique properties that enhance functional programming in Clojure.
We'll cover the following...
Properties
Clojure has a huge set of data structures that have some properties in common:
They are immutable, readable, and persistent, so they always preserve the previous version of themselves when they’re modified.
They allow value equality semantics in any comparison of equals, so we can use
=to validate them.They provide hash values, which are numeric values that uniquely identify data, in a good way.
Furthermore, the abundance of data structures has an impact on the JVM due to its support for all types found in Java.
The nil value
In Clojure, nil is a possible value of any data type. It’s similar to null used in other programming languages, so it’s a representation of an empty value. Conditionals in Clojure are based around nil and false, similar to other languages; nil equates to falsity in logic. Moreover, by default, if a function in Clojure hasn’t received a return type, nil is always returned.
Furthermore, in Clojure, we have a fundamental library called clojure.core, ...