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))
          (let ((source-getter
                 (array-getter source))
                 (array-setter destination))
                 (array-domain destination)))
             (case (interval-dimension domain)
               ((1) (lambda (i)
                      (destination-setter (source-getter 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)))
                (lambda multi-index
                  (apply destination-setter
                         (apply source-getter multi-index)

Search for "array-assign!" here:

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

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"

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?