In the Wild

If you look at real-world code you will discover that Clojure programmers overwhelmingly choose the vector over the list for their sequential-data-structure needs. Thus, finding real-world uses of the vector brings new meaning to the word easy. Vectors are found at the heart of just about every Clojure program. Take, for example, this bit of real-world code:

 (​defn​ escape-html [string]
  (replace-all string [[​"&"​ ​"&"​]
  [​"\""​ ​"""​]
  [​"<"​ ​"&lt;"​]
  [​">"​ ​"&gt;"​]]))

Clearly the preceding function—which I adopted from the Clostache HTML templating library[9]—defines a function called escape-html. Equally clear is that the escape-html function takes a single parameter with the less-than-enlightening name of ...

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.