chickadee » generalized-arrays » reverse-zip-array

zip-array arrayprocedure
reverse-zip-array arrayprocedure

Transducer that zips the contents of the provided array onto the transduction. reverse-zip-array works similar to zip-array, but zips the array onto the transduction in reverse-lexicographic ordering.

 
(import generalized-arrays
        transducers
        test)

(define a
  (make-array-from-storage vector-storage-class
                           (vector 3 3)
                           (vector 'a 'b 'c
                                   'd 'e 'f
                                   'g 'h 'i)))

(test "Zip array to transduction"
      (list (cons 1 'a) (cons 2 'b) (cons 3 'c))
      (transduce list-fold
                 (zip-array a)
                 (collect-list)
                 (list 1 2 3))))

(test "Reverse zip array to transduction"
      (list (cons 1 'i) (cons 2 'h) (cons 3 'g))
      (transduce list-fold
                 (reverse-zip-array a)
                 (collect-list)
                 (list 1 2 3)))