首页 > Linux操作系统 > Linux操作系统 > lisp 习题 post+
> (pos+ '(7 5 1 4)) (7 6 3 7)
| CL-USER> (defun post+ (lst) (and (listp lst) (let ((n (length lst)) (x nil)) (dolist (obj lst) (push (+ (nth (- n 1)lst) (- n 1)) x) (setf n ( - n 1))) x))) CL-USER> (post+ 1) NIL CL-USER> (post+ '(0 1 2 3 4)) (0 2 4 6 8) CL-USER> (post+ (list 1 2 3 4)) (1 3 5 7) |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/133735/viewspace-740236/ ,如需转载,请注明出处,否则将追究法律责任。