开发者

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

开发者 https://www.devze.com 2022-12-10 02:43 出处:网络
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.

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

精彩评论

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

关注公众号