Concatenate lists or strings together
Examples: (concatenate 'string "ab" "cd" "ef") ; equals "abcdef" (concatenate 'string "ab") ; equals "ab" (concatenate 'list '(a b) '(c d) '(e f)) ; equals '(a b c d e f) (concatenate 'list) ; equals nil General Form: (concatenate result-type x1 x2 ... xn)
where
Note: We do *not* try to comply with the Lisp language's insistence that
Macro:
(defmacro concatenate (result-type &rest sequences) (declare (xargs :guard (or (equal result-type ''string) (equal result-type ''list)))) (cond ((equal result-type ''string) (cond ((and sequences (cdr sequences) (null (cddr sequences))) (list 'string-append (car sequences) (cadr sequences))) (t (list 'string-append-lst (cons 'list sequences))))) ((endp sequences) nil) (t (cons 'append (append sequences (list nil))))))