[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access time of elements Re: Bad things []

This page is part of the web mail archives of SRFI 25 from before July 7th, 2015. The new archives for SRFI 25 contain all messages, not just those from before July 7th, 2015.

David Rush writes:

> Per Bothner writes:
>> The main problem with (2) is that it adds a new concept - an "index
>> object" data-type.
> Yep, but it actually adds value, I think. Sooner or later people are
> going to want slicing; having the index-object present helps pave
> the way for that.

It's easy to pick all kinds of parts of an array even with the current
mechanisms. Take the third slice from front of a 4*4*4 cube as a 4*4
matrix (assume zero based, depth first):

  (share-array cube (shape 0 4 0 4) (lambda (r k) (values 2 r k))).

Equally easy to pick second slice from top, or rightmost slice.

And I wrote a very general (every-nth arr d n) that shares every nth
slice of arr along dimension d. For the identity matrix i_4,

(every-nth i_4 0 3)   (every-nth i_4 1 3) 
==>                   ==>                 
1 0 0 0               1 0                 
0 0 0 1               0 0                 
                      0 0                 
                      0 1                 

It's a dozen lines, including a non-destructive auxiliary for changing
the dth element of a list (the arguments to the affine map).