Reverse
Reverse a list or string
(Reverse x) is the result of reversing the order of the
elements of the list or string x.
The guard for reverse requires that its argument is a true list
or a string.
Reverse is defined in Common Lisp. See any Common Lisp documentation
for more information.
Function: reverse
(defun reverse (x)
(declare (xargs :guard (or (true-listp x) (stringp x))))
(cond ((stringp x)
(coerce (revappend (coerce x 'list) nil)
'string))
(t (revappend x nil))))
Subtopics
- Nrev
- A safe mechanism for implementing something like nreverse, for
writing tail-recursive functions that use less memory by avoiding the final
reverse step.
- Rev
- Logically simple alternative to reverse for lists.
- Std/lists/reverse
- Lemmas about reverse available in the std/lists
library.
- Hons-reverse
- REVERSE using HONS instead of CONS