On Oct 8, 9:54 am, Martin DeMello <[EMAIL PROTECTED]> wrote:
> That was my first thought, but I was hoping there was a library for
> this already. It seems to be a surprisingly uncommon use case (not
> just in clojure, I've ended up implementing something like that in
> several languages) - I'd have thought 2d rectangular arrays were a lot
> more popular a data structure than that.
Java doesn't even have real 2-D arrays, just syntactic sugar for array-
of-arrays.  Storage of the rows (indexing is row-oriented in Java,
like in C) is not guaranteed contiguous because Java's representation
of 2-D arrays is an array-of-references-to-arrays (e.g., each "row"
can have a different length) rather than a contiguous chunk of storage
mapped to 2-D indices.  It shouldn't be hard to sugar yourself up such
a mapping.  However, if you find yourself doing this a lot, you might
want to think about a more Clojure-like idiom that doesn't require
destructive updates and minimizes consing for local changes (e.g., a
quadtree).

mfh

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to