Re: Ideas for an advanced array procedure SRFI Bradley Lucier 05 May 2022 15:36 UTC

These suggestions were made for SRFI 122; here are related items in the
weird-domains branch of SRFI 231:

https://github.com/gambiteer/srfi-231/tree/weird-domains

On 1/11/20 6:57 PM, John Cowan wrote:
> This is very preliminary, and was compiled by scouring features from
> ISO/IEC 13751, Extended APL.
>
> (array-depth a) => examines all elements and recursively calls itself on
> any elements that are arrays.  Returns one more than its deepest array
> element.

Added as an example to the SRFI document.

>
> array-recursive-get and array-recursive-set: the same as calling the
> array's getter and setter, but additional arguments are used to index an
> element that is itself an array recursively until the arguments run
> out.  It is an error if there aren't enough arguments to index the array
> or a particular nested array.

A partial substitute is to call the getter of a curried array.

> (recursive-array->list a) => similar to array->list, but any elements
> that are arrays are recursively converted to lists.  This result can
> then be flattened to find all elements in all enclosed arrays.

array->list*, array->vector*, with inverses list*->array, vector*->array

> (iterated-list->specialized-array list . <make-specialized-array args>)
> => similar to list->specialized-array but if the list is exhausted,
> repeats its elements until the result array is full.

No.

> (array-fold-on proc knil a dim) => like array-fold, but instead of
> processing all elements in lexicographic order, divides a into
> sub-arrays on dimension dim and folds over the the sub-arrays instead.

Added as an example to the SRFI document

> (array-inner-product sum product a1 a2) => constructs the inner product
> (dot product, matrix product) of a1 and a2, using the dyadic function
> *product* to multiply individual elements and the variadic function
> *sum* to total them.  It is an error if the bounds of the last dimension
> of a1 are not equal to the bounds of the first dimension of a2; the
> bounds of the result are all the remaining bounds of a1 followed by all
> the remaining bounds of a2.

array-inner-product

> (array-catenate a1 a2 dim) => glues together a1 and a2, which must have
> the same interval, along dimension dim.  We also need array-laminate,
> but I have not worked that out yet.

array-append, array-block, with inverse array-tile.

There's also array-stack for array-laminate.

> (array-find = a vec) => searches through the elements of a in
> lexicographic order looking for the first element that is equal (in the
> sense of the = argument) to an element of vec.  The result is a vector
> the same size as vec containing the indices of these occurrences, or #f
> if there is no occurrence.

No.

> (array-grade < a dim) => slices a into subarrays along dimension dim and
> returns a vector which specifies the permutation of the slices along
> dimension dim that puts them in increasing order in the sense of the <
> argument.

No.

>
> (Of course any of these could be incorporated into SRFI 122bis.)
>
> A few more ideas not yet worked out: array-broadcast, array-expand,
> array-replicate.
>
> Comments?
>
>
>
> John Cowan http://vrici.lojban.org/~cowan
> <http://vrici.lojban.org/~cowan> xxxxxx@ccil.org <mailto:xxxxxx@ccil.org>
> This great college [Trinity], of this ancient university [Cambridge],
> has seen some strange sights. It has seen Wordsworth drunk and Porson
> sober. And here am I, a better poet than Porson, and a better scholar
> than Wordsworth, somewhere betwixt and between.  --A.E. Housman
>