値が 0 または 1 のこのグリッドがあるとします。
(def grid [[1 0 1]
[1 0 0]
[1 0 1]])
grid
ここで、リスト内包表記を使用して、HTML Hiccup のような形式に変換したいと考えています。
(defn cell-component [is-it-1 key]
^{:key key} [:td (if (= is-it-1 1) {:class "is-it-1"})])
(defn grid-html []
([:table
[:tbody
(for [row grid]
^{:key row} [:tr
(for [cell row]
(cell-component cell how-i-can-generate-a-index?))])]]))
unique index
テーブルは正しく生成されますが、を作成する方法がわかりませんtd
。どうhow-i-can-generate-a-index?
あるべきですか?