30% Therapy – 40% Practice – 30% Work project

Clojure – StructMaps



StructMaps are used for creating structures in Clojure. For example, if you wanted to create a structure which comprised of an Employee Name and Employeeid, you can do that with StructMaps.

The following operations are possible in Clojure with regards to StructMaps.

Sr.No. Operations & Description
1

This function is used for defining the structure which is required.

2

This function is used to define a structure object of the type, which is created by the defstruct operation.

3

This function is used to specifically assign values to key values by explicitly defining which values get assigned to which keys in the structure.

4

Individual fields of the structure can be accessed by accessing the keys along with the structure object.

5

By default structures are also immutable, so if we try to change the value of a particular key, it will not change.

6

Since structures are immutable, the only way that another key can be added to the structure is via the creation of a new structure. An example on how this can be achieved is shown in the following program.

Translate »