Pad a character-list with spaces on the right.
(rpadchars x len) extends the character list
(rpadchars '(#\f #\o #\o) 5) --> '(#\f #\o #\o #\Space #\Space)
This is completely dumb: we don't try to account for newlines, tabs, or
anything like that, and just add
If no new spaces are needed,
Function:
(defun rpadchars (x len) (declare (xargs :guard (and (character-listp x) (natp len))) (type integer len)) (mbe :logic (append (make-character-list x) (repeat (nfix (- (nfix len) (len x))) #\Space)) :exec (let* ((x-len (length (the list x))) (diff (- len x-len))) (if (> diff 0) (append x (repeat diff #\Space)) x))))
Theorem:
(defthm character-listp-of-rpadchars (character-listp (rpadchars x len)))
Theorem:
(defthm len-of-rpadchars (equal (len (rpadchars x len)) (max (len x) (nfix len))))
Theorem:
(defthm charlisteqv-implies-equal-rpadchars-1 (implies (charlisteqv x x-equiv) (equal (rpadchars x len) (rpadchars x-equiv len))) :rule-classes (:congruence))
Theorem:
(defthm icharlisteqv-implies-icharlisteqv-rpadchars-1 (implies (icharlisteqv x x-equiv) (icharlisteqv (rpadchars x len) (rpadchars x-equiv len))) :rule-classes (:congruence))