Subject: Re: Aref on steroids
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 10 Jun 2009 04:28:13 -0500
Newsgroups: comp.lang.lisp
Message-ID: <5J6dnXYNGqMw4bLXnZ2dnUVZ_radnZ2d@speakeasy.net>
Slobodan Blazeski  <slobodan.blazeski@gmail.com> wrote:
+---------------
| I have another problem with looping over multi dimensional arrays:
| I need an array *accessor* with elided indices for example
| (defun elide (array &rest subscripts)
| ...
| For foo  being 2 dimensional array (2 5)
| 0 1 2 3 4
| 5 6 7 8 9
...
| However for every subscript that's not an integer:
| (elide foo 1 t)
| #(5 6 7 8 9)
| 
| (elide foo t 4)
| #(4 9)
+---------------

People often call this function "slicing" an array (rather than eliding).
There was some discussion of this here back in February of this year
with the "Subject: multidimensional array slices". In particular,
Tamas Papp pointed to this package:

    If you want the general slices, I wrote an experimental (but working)
    package which might do what you want.  You can find it here:

    http://www.princeton.edu/~tpapp/index.html#affi
    affi
    An affine indexing package that provides convenience functions for
    traversing slices of arrays, optionally with index permutations and
    other convenient transformations. A driver clause for iterate is
    provided, along with map-subarray, a simple yet powerful function
    for mapping arrays into each other using affine indexes.
    [GIT repo] [tarball]

Marco Antoniotti also discussed his MAKE-ARRAY-SLICE function.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607