superfluous functions? Jamison Hope (29 Sep 2015 16:57 UTC)
Re: superfluous functions? Bradley Lucier (29 Sep 2015 17:08 UTC)
Re: superfluous functions? Jamison Hope (29 Sep 2015 17:48 UTC)
Re: superfluous functions? Bradley Lucier (07 Oct 2015 01:15 UTC)
Re: superfluous functions? Jamison Hope (11 Oct 2015 14:45 UTC)
Re: superfluous functions? Bradley Lucier (16 Oct 2015 17:44 UTC)

Re: superfluous functions? Bradley Lucier 07 Oct 2015 01:15 UTC

How's this for a new API and description for array-curry (still in
progress):

Procedure: array-curry array outer-dimension [ subarray-type 'immutable ]

If array is an array whose domain is an interval [l0, u0) x ... x [ld-1,
ud-1) and outer-dimension is an exact integer strictly between 0 and d,
then array-curry returns an (immutable) array with domain [l0, u0) x
...x [louter-dimension-1, uouter-dimension-1), each of whose entries is
in itself an array with domain [louter-dimension, uouter-dimension) x
... x [ld-1, ud-1).

The type of the subarrays is determined by the optional argument
subarray-type in combination with the type of the input array.

If subarray-type is 'mutable, and the input array is mutable (which
includes specialized arrays), then each subarray is mutable.

If subarray-type is 'specialized and the input array is specialized,
then each subarray is specialized.

More precisely, if

    0 < outer-dimension < (interval-dimension (array-domain array))

then array-curry returns a result as follows: If subarray-type is not
given, or is given as 'immutable, then array-curry returns

(call-with-values
    (lambda () (interval-curry (array-domain array) outer-dimension))
  (lambda (outer-interval inner-interval)
    (array outer-interval
	   (lambda outer-multi-index
	     (array inner-interval
		    (lambda inner-multi-index
		      (apply (array-getter array) (append outer-multi-index
inner-multi-index))))))))

If subarray-type is given as 'mutable and the input array is mutable,
then array-curry returns

(call-with-values
    (lambda () (interval-curry (array-domain array) outer-dimension))
  (lambda (outer-interval inner-interval)
    (array outer-interval
	   (lambda outer-multi-index
	     (mutable-array inner-interval
			    (lambda inner-multi-index
			      (apply (array-getter array) (append outer-multi-index
inner-multi-index)))
			    (lambda (v . inner-multi-index)
			      (apply (array-setter array) v (append outer-multi-index
inner-multi-index))))))))

And if subarray-type is given as 'specialized and the input array is
specialized, then array-curry returns

(call-with-values
    (lambda () (interval-curry (specialized-array-domain array)
outer-dimension))
  (lambda (outer-interval inner-interval)
    (array outer-interval
	   (lambda outer-multi-index
	     (specialized-array-share array
				      outer-interval
				      (lambda inner-multi-index
					(apply values (append outer-multi-index inner-multi-index))))))))

It is an error to call array-curry if its arguments do not satisfy these
conditions.