> Jesse,
> Could I see your own version.
Haha, I was afraid someone would say this.
Here is my embarrassingly bad (but working) version:
(defn build-table []
(def num-cols 3)
(def selected-row 0)
(def selected-col 0)
(def all-strings ["apple" "cat" "dog" "" "frog" "elephant"
"gorilla"])
(defn new_cell [string row col]
(defn bg-color []
(if (and (= col selected-col)
(= row selected-row))
"d0e0ff"
"cfcfdf"))
(str "<td bgcolor=#" (bg-color) ">" "<font color=#0000cc>"
(first string) "</font>" (.substring string 1 (.length
string))
"</td>"))
(loop [row 0 col 0
table_contents "<table cellpadding=30 bgcolor=#6666aa>\n<tr>
\n"
strings all-strings]
(if strings
(if (not= (first strings) "")
(if (>= col num-cols)
(recur (inc row) 0 (str table_contents "</tr>\n<tr>")
strings)
(recur row (inc col)
(str table_contents (new_cell (first strings) row col))
(rest strings)))
(recur row col table_contents (rest strings)))
(str table_contents "</tr>\n</table>"))))
I actually got it working before reading any of the replies here. So
I'll probably take some of these suggestions and use them to improve
the code.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---