Next: , Previous: , Up: vectors   [Index]


24.9 Padding and trimming

Function: %vector-pad requested-len fill-item vec start past
Function: %vector-pad-right requested-len fill-item vec start past
Macro: vector-pad V requested-len
Macro: vector-pad V requested-len fill-item
Macro: vector-pad-right V requested-len
Macro: vector-pad-right V requested-len fill-item

Build a vector of length requested-len comprised of vec padded on the left or right by as many occurrences of the item fill-item as needed. Always return a newly allocated vector.

If vec has more than requested-len items, it is truncated on the left or right to length requested-len. For the macros: fill-item defaults to #f.

(vector-pad '#(1 2 3))           ⇒ #(#f #f 1 2 3)
(vector-pad '#(1 2 3 4 5) 5)     ⇒ #(1 2 3 4 5)
(vector-pad '#(9 9 1 2 3 4 5) 5) ⇒ #(1 2 3 4 5)
Function: %vector-trim pred vec start past
Function: %vector-trim-right pred vec start past
Function: %vector-trim-both pred vec start past
Macro: vector-trim V pred
Macro: vector-trim-right V pred
Macro: vector-trim-both V pred

Trim the selected subvector of vec by skipping over all items on the left/on the right/on both sides that satisfy pred: A test predicate that is applied to the items in vec, an item causing it to return true is skipped.

Always return a newly allocated vector.