chickadee » generalized-arrays » reverse-flatten-array

flatten-arrayprocedure
reverse-flatten-arrayprocedure

Transducers that flatten arrays into their contained values in a transduction. flatten-array flattens the elements of the array into the transduction in lexicographic ordering. reverse-flatten-array is similar to flatten-array, but flattens the values in reverse-lexicographic ordering.

 
(import generalized-arrays
        transducers
        test)

(define a
  (make-array-from-storage vector-storage-class
                           (vector 3 3)
                           (vector 1 2 3
                                   4 5 6
                                   7 8 9)))

(test "Flattening a list of arrays"
      (vector 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9)
      (transduce list-fold
                 flatten-array
                 (collect-vector)
                 (list a a)))