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 |
defstruct
this function is used for defining the structure which is required. |
| 2 |
struct
this function is used to define a structure object of the type, which is created by the defstruct operation. |
| 3 |
struct-map
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 |
accessing individual fields
individual fields of the structure can be accessed by accessing the keys along with the structure object. |
| 5 |
immutable nature
by default structures are also immutable, so if we try to change the value of a particular key, it will not change. |
| 6 |
adding a new key to the structure
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. |