On Oct 10, 10:56 am, Martin DeMello <[EMAIL PROTECTED]> wrote:
> On Oct 9, 12:29 pm, "Mark H." <[EMAIL PROTECTED]> wrote:
>
> > 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).
>
> Interesting idea, but typical operations will be iterating along the
> cells in a given row or column, so a 2d doubly-linked list would
> probably work better than any sort of space-partitioning tree. But
> then I lose easy random access to a cell. Vector(-of-vectors) and {[x
> y] => cell} do seem like my best bets here.
Depends on what you want with the data structure. Some people might
want to take slices of matrices -- e.g., the following (in Matlab
notation):
A( 1:2:end, 1:3:end )
which is a matrix containing every second row and every third column
of A. Implementing this is much easier and more efficient if all the
data is in a single flat array, than if it's a vector of vectors.
Also, imagine the pain of matrix-matrix multiplication with a list-of-
lists. But if you always mean to iterate rowwise over your 2-D array,
then list-of-lists is just fine.
mfh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---