Advertisement
Guest User

first-to-last

a guest
Jun 7th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.28 KB | None | 0 0
  1. (defun first-to-last (L)
  2.   (labels ((fi-la (l)
  3.          (append (cdr l) (list (car l))))
  4.        (rec (x)
  5.          (cond ((null x) x)
  6.            ((atom (car x)) (cons (car x)
  7.                      (first-to-last (cdr x))))
  8.            (t (cons (fi-la (first-to-last (car x)))
  9.                 (rec (cdr x)))))))
  10.     (rec L)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement