6. Recursion and Looping
Activity 6.01: Generating HTML from Clojure Vectors
Solution:
- We'll use
clojure.stringin our solution. It is not strictly necessary, butclojure.string/joinis a very convenient function. Becauseclojure.stringis a standard Clojure namespace, adeps.ednfile containing only an empty map is sufficient for this activity:(ns my-hiccup  (:require [clojure.string :as string]))
- Here are the smaller functions that we'll use later in the main HTML-producing function:
(defn attributes [m] Â (clojure.string/join " " Â Â Â Â Â Â Â Â Â Â Â Â (map (fn [[k v]] Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (if (string? v) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (str (name k) "=\"" v "\"") Â Â Â Â Â Â Â Â Â Â Â ...