chickadee » srfi-132 » vector-delete-neighbor-dups!

vector-delete-neighbor-dups! = v #!optional start endprocedure

This procedure reuses its input vector to hold the answer, packing it into the index range [start, newend), where newend is the non-negative exact integer that is returned as its value. The vector is not altered outside the range [start, newend).

Examples:

(list-delete-neighbor-dups = '(1 1 2 7 7 7 0 -2 -2))
           ⇒ (1 2 7 0 -2)

(vector-delete-neighbor-dups = '#(1 1 2 7 7 7 0 -2 -2))
           ⇒ #(1 2 7 0 -2)

(vector-delete-neighbor-dups < '#(1 1 2 7 7 7 0 -2 -2) 3 7))
           ⇒ #(7 0 -2)

;; Result left in v[3,9):
(let ((v (vector 0 0 0 1 1 2 2 3 3 4 4 5 5 6 6)))
  (cons (vector-delete-neighbor-dups! < v 3)
        v))
              ⇒ (9 . #(0 0 0 1 2 3 4 5 6 4 4 5 5 6 6))