On 25.05.2009, at 21:08, aperotte wrote:

> Say that you're dealing with a structure of x dimensions.  In this
> frame, imagine that you have a list of x-1 dimensional objects in a
> list that is as long as the xth dimension.  You can cons up these
> things that are n-1 in dimensionality and use nth as a linear index
> for these n-1 dimensional structures.  In other words, nth should be
> used when operating on the outer-most/last dimension, whereas the
> index method is intended to be used when you're treating the data
> structure as a whole.  Let me know if my explanation isn't clear.

It's perfectly clear and quite consistent with my expectations. It's  
also very close to how multiarrays in Python (NumPy) work. An n- 
dimensional array works as much as possible like a nested list/vector  
with n levels of nesting. And that's why I expected the two expressions
        (.index m (int-array [0 1]))
and
        (-> m (nth 0) (nth 1))
to be equivalent, except for performance considerations.

>> -> #<PersistentMatrix
>> [[1, 2]
>> [3, 4]
>> [5, 6]]>
>
> Also, the printing isn't correct yet.  The rows should be switched
> with the columns, but that didn't seem trivial, so I have postponed it
> for a while.

Well, the current order seemed normal to me. Pretty much all array  
languages I know use the first index for the rows.

> This shouldn't happen.  This should actually raise an exception.  I
> intended index only to be used when you specify an index for all of
> the dimensions.

OK.

Konrad.

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to