开发者

What is the best way to initialize all the elements of a JTable with Clojure?

Sorry if this is a bit of a noob question but I am still getting used to functional programming.

I want to write a simple Sudoku solver as an exercise.

One of my plans is to create a JTable with 9 rows and 9 columns and initialize them all with the string "123456789" as a starting position.

If I have a TableModel I can define a function to initialize a single cell like this:

(defn 开发者_如何学运维initCell
 "inits a cell with 123456789"
 [dm row col]
 (doto dm (.setValueAt "123456789" row col)))

Now what is the most Clojure like way to get this called for all cells in the 9x9 table?


Possibly like this:

(doseq [x (range 10) y (range 10)]
  (initCell dm x y))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜