Lexicographical access to arrays John Cowan (09 Apr 2026 18:59 UTC)
Re: Lexicographical access to arrays Per Bothner (09 Apr 2026 19:47 UTC)
Re: Lexicographical access to arrays Alex Shinn (09 Apr 2026 23:48 UTC)
Re: Lexicographical access to arrays Bradley Lucier (10 Apr 2026 00:22 UTC)
Re: Lexicographical access to arrays Per Bothner (10 Apr 2026 01:48 UTC)
Re: Lexicographical access to arrays John Cowan (10 Apr 2026 05:52 UTC)
Re: Lexicographical access to arrays Bradley Lucier (10 Apr 2026 15:33 UTC)
Re: Lexicographical access to arrays Bradley Lucier (10 Apr 2026 15:36 UTC)
Re: Lexicographical access to arrays Bradley Lucier (11 Apr 2026 00:32 UTC)
Re: Lexicographical access to arrays John Cowan (11 Apr 2026 04:03 UTC)
Re: Lexicographical access to arrays Bradley Lucier (11 Apr 2026 17:37 UTC)

Re: Lexicographical access to arrays Bradley Lucier 10 Apr 2026 15:32 UTC

On 4/10/26 01:52, John Cowan wrote:
> It would be fine if this only worked for specialized arrays, where the
> elements*are* contiguous.  In that case you don't have to do all the
> divisions and remainders: you look down at the storage-class body and
> work from that.

OK, I understand.  Currently, e.g,

(apply array-fold-left op id arrays)

is implemented as

(if (and (fx<= (length arrays) 4)
          (every (lambda (A)
                   (and (specialized-array? A) (%%array-packed? A)))
                 arrays))
     (case (length arrays)
       ((1)
        (let* ((domain (%%array-domain (car arrays)))
               (lowers (%%interval-lower-bounds->list domain))
               (number-of-elements (%%interval-volume domain))
               (base_0 (apply (%%array-indexer (list-ref arrays 0))
                              lowers))
               (getter_0
                (storage-class-getter
                 (%%array-storage-class (list-ref arrays 0))))
               (body_0 (%%array-body (list-ref arrays 0))))
          (do ((elements-remaining
                number-of-elements
                (fx- elements-remaining 1))
               (i_0 base_0 (fx+ i_0 1))
               (result id (op result (getter_0 body_0 i_0))))
              ((eqv? elements-remaining 0) result))))
;;; cases for 2 to 4 arrays removed
     )
;;; now the general case
     (%%interval-fold-left
      op
      id
      (%%array-domain (car arrays))
      (map %%array-unsafe-getter arrays)))

Would adding an example like this under array-packed?