Concatenate a list of strings with some separator between.
(join x separator) → joined
(join x separator) joins together the list of strings
(join '("a" "b" "c") ".") = "a.b.c" (join '("a" "b" "c") "->") = "a->b->c"
We always return a string; an empty
Any sort of string concatenation is slow, but
Function:
(defun join-aux (x separator acc) (declare (xargs :guard (string-listp x)) (type string separator)) (cond ((atom x) acc) ((atom (cdr x)) (revappend-chars (car x) acc)) (t (let* ((acc (revappend-chars (car x) acc)) (acc (revappend-chars separator acc))) (join-aux (cdr x) separator acc)))))
Function:
(defun join$inline (x separator) (declare (type string separator)) (declare (xargs :guard (string-listp x))) (let ((acl2::__function__ 'join)) (declare (ignorable acl2::__function__)) (mbe :logic (cond ((atom x) "") ((atom (cdr x)) (str-fix (car x))) (t (cat (car x) separator (join (cdr x) separator)))) :exec (rchars-to-string (join-aux x separator nil)))))
Theorem:
(defthm stringp-of-join (b* ((joined (join$inline x separator))) (stringp joined)) :rule-classes :type-prescription)
Theorem:
(defthm join-aux-removal (implies (and (string-listp x) (stringp separator)) (equal (join-aux x separator acc) (revappend (coerce (join x separator) 'list) acc))))
Theorem:
(defthm list-equiv-implies-equal-join-1 (implies (list-equiv x x-equiv) (equal (join x separator) (join x-equiv separator))) :rule-classes (:congruence))
Theorem:
(defthm streqv-implies-equal-join-2 (implies (streqv separator separator-equiv) (equal (join x separator) (join x separator-equiv))) :rule-classes (:congruence))
Theorem:
(defthm istreqv-implies-istreqv-join-2 (implies (istreqv separator separator-equiv) (istreqv (join x separator) (join x separator-equiv))) :rule-classes (:congruence))