What is the best way to initialize all JTable elements using Clojure?

Sorry if this is a bit of a nob question, but I'm still 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 the starting position.

If I have a TableModel, I can define a function to initialize an individual 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 way to get this for all 9x9 table cells?

+2


source to share


1 answer


Perhaps like this:



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

      

+4


source







All Articles