Advertisement
Guest User

Better nreverse

a guest
Jun 22nd, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.28 KB | None | 0 0
  1. (defun nreverse (list)
  2.   (let ((result '())
  3.         (remaining list))
  4.     (loop until (endp remaining)
  5.           do (let ((temp (cdr remaining)))
  6.                (setf (cdr remaining) result)
  7.                (setf result remaining)
  8.                (setf remaining temp)))
  9.     result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement