practicalli / clojure

Practicalli Clojure REPL Driven Development
https://practical.li/clojure/
Creative Commons Attribution Share Alike 4.0 International
89 stars 36 forks source link

Clojure Idiom - tuple #421

Open practicalli-johnny opened 2 years ago

practicalli-johnny commented 2 years ago

A Tuple in Clojure is a very simple data structure, usually represented as two related values in a vector

[value1 value2]

The value of a tuple is in its simplicity, although greater responsibility is required to use the tuple values in the desired way.

The tuple provides less structure and meaning than a hash-map, as the values in the tuple have no explicit key (although the first value could be perceived as the key, but then a hash-map representation would feel more appropriate)

Review Clojure Design Club discussions on tuples for more examples of how they are used.