On Tue, Oct 7, 2008 at 9:30 PM, Martin DeMello <[EMAIL PROTECTED]> wrote: > > How do you make a two-dimensional array of a given size? (e.g. (make- > array '(i j)) in common lisp) > > I want to do stuff like, e.g., representing a chessboard, where I can > index into cells and update them.
For something like that, I think I'd want to use a clojure persistent data structure -- perhaps a sorted-map or hash-map using a vector for each key: (assoc board [4 1] "black king") Rich used a vector of vectors in his ants demo: (let [row (vec (replicate 8 nil)) board (vec (replicate row 8))] (assoc board 1 (assoc (board 1) 5 "black pawn"))) If you're really sure you want a non-thread-safe mutable Java array, you can get an 8x8 array of Objects: (make-array Object 8 8) --Chouser --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---