Additional procedure: array-assign! Bradley Lucier (24 Jan 2017 19:29 UTC)
Re: Additional procedure: array-assign! Arthur A. Gleckler (29 Jan 2017 18:34 UTC)
Re: Additional procedure: array-assign! Bradley Lucier (30 Jan 2017 21:25 UTC)
Re: Additional procedure: array-assign! Arthur A. Gleckler (31 Jan 2017 23:24 UTC)
Re: Additional procedure: array-assign! Bradley Lucier (01 Feb 2017 04:06 UTC)
Re: Additional procedure: array-assign! Arthur A. Gleckler (01 Feb 2017 05:37 UTC)

Additional procedure: array-assign! Bradley Lucier 24 Jan 2017 19:29 UTC

I've realized that I left out an important procedure

(define (array-assign! destination source)
   (cond ((not (mutable-array? destination))
          (error "array-assign!: The first argument is not a mutable
array: " destination source))
         ((not (array? source))
          (error "array-assign!: The second argument is not an array: "
destination source))
         ((not (interval= (array-domain destination)
                          (array-domain source)))
          (error "array-assign!: The arguments do not have the same
domain: " destination source))
         (else
          (let ((source-getter
                 (array-getter source))
                (destination-setter
                 (array-setter destination))
                (domain
                 (array-domain destination)))
            (interval-for-each
             (case (interval-dimension domain)
               ((1) (lambda (i)
                      (destination-setter (source-getter i)
                                          i)))
               ((2) (lambda (i j)
                      (destination-setter (source-getter i j)
                                          i j)))
               ((3) (lambda (i j k)
                      (destination-setter (source-getter i j k)
                                          i j k)))
               ((4) (lambda (i j k l)
                      (destination-setter (source-getter i j k l)
                                          i j k l)))
               (else
                (lambda multi-index
                  (apply destination-setter
                         (apply source-getter multi-index)
                         multi-index))))
             domain)))))

Search for "array-assign!" here:

http://www.math.purdue.edu/~lucier/srfi-122.html

for documentation and an example of its use in Gaussian elimination (LU
decomposition).

Because of my own programming style, I didn't realize for a long time
that such a procedure is necessary, but it *is* necessary for certain
applications if you want to get away from what I call "word-at-a-time"
array computing.  So now I regret that it wasn't included in the "final"
SRFI.

I plan to add this procedure, documentation, and test code to my own
github repository.  If I could add it to the SRFI, I would, but I'm
content with just adding it to my own repository and marking it as an
"augmented" SRFI 122, or something like that.

What do people think?

Brad