`struct-map` creates a Clojure struct instance from a struct definition and key-value pairs: `(struct-map s & inits)`. Use it when input arrives as named fields rather than values in a fixed order. section 11.1.4
The definition supplies the instance’s required keys:
- Create a definition with `create-struct`, or bind one with `defstruct`. section 11.1.4
- Pass initialization entries as alternating keys and values. Defined keys omitted from the entries receive `nil`; additional keys are retained. section 11.1.4
- A defined key cannot be removed from the resulting struct with `dissoc`; that operation raises a `RuntimeException`. section 11.1.4
Normalize partially populated coordinates
```clojure (defstruct waypoint :type :lat :lon :id) (struct-map waypoint :lat "18.3112" :lon "3.1314" :id "XVA" :alt 150) ;; {:type nil, :lat "18.3112", :lon "3.1314", :id "XVA", :alt 150} ``` The missing `:type` becomes `nil`, while the extra `:alt` remains available. For a sequence of ordinary maps, `(map #(apply struct-map waypoint (mapcat identity %)) coordinates)` converts each map in the same way. section 11.1.4
Choose `struct` instead when values already match the definition’s key order: it assigns them positionally and rejects more values than defined keys. `struct-map` is also used in `clojure.xml`’s nested representation of XML nodes, with `:tag`, `:attrs`, and `:content` fields. For everyday Clojure programming, `defrecord` generally replaces the need for structs. section 11.1.4 section 22.1
