chickadee » generalized-arrays » reverse-flatten-interval

flatten-intervalprocedure
reverse-flatten-intervalprocedure

Transducer that flattens transduced intervals either in forward or reverse order.

 
(import (generalized-arrays intervals)
        (transducers)
        (test))

(test "Flattening intervals constructed by a separate transducer procedure"
      (list (vector 0 0)
            (vector 0 1)
            (vector 1 0)
            (vector 1 1)
            (vector 5 5)
            (vector 5 6)
            (vector 6 5)
            (vector 6 6))
      (transduce list-fold
                 (compose
                   (zip-list (list (vector 2 2) (vector 7 7)))
                   (map (lambda (pair) (apply make-interval pair)))
                   flatten-interval)
                 (collect-list)
                 (list (vector 0 0) (vector 5 5))))