Pad a character-list with spaces on the left.
(lpadchars x len) extends the character list
(lpadchars '(#\f #\o #\o) 5) --> '(#\Space #\Space #\f #\o #\o)
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 lpadchars (x len) (declare (xargs :guard (and (character-listp x) (natp len))) (type integer len)) (mbe :logic (append (repeat (nfix (- (nfix len) (len x))) #\Space) (make-character-list x)) :exec (let* ((x-len (length x)) (diff (- len x-len))) (if (< 0 diff) (make-list-ac diff #\Space x) x))))
Theorem:
(defthm character-listp-of-lpadchars (character-listp (lpadchars x len)))
Theorem:
(defthm len-of-lpadchars (equal (len (lpadchars x len)) (max (len x) (nfix len))))
Theorem:
(defthm charlisteqv-implies-equal-lpadchars-1 (implies (charlisteqv x x-equiv) (equal (lpadchars x len) (lpadchars x-equiv len))) :rule-classes (:congruence))
Theorem:
(defthm icharlisteqv-implies-icharlisteqv-lpadchars-1 (implies (icharlisteqv x x-equiv) (icharlisteqv (lpadchars x len) (lpadchars x-equiv len))) :rule-classes (:congruence))