views:

74

answers:

1

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?

+1  A: 

Possibly like this:

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