Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; http://stackoverflow.com/q/20393589/1281433
- ;; Joshua Taylor, 4 December 2013
- (defun length1 (list)
- (if (endp list)
- 0
- (+ 1 (length1 (rest list)))))
- (defun length2 (list)
- (labels ((l2 (list len)
- (if (endp list)
- len
- (l2 (rest list) (1+ len)))))
- (l2 list 0)))
- (defun length3 (list)
- (do ((list list (rest list))
- (len 0 (1+ len)))
- ((endp list) len)))
- (defun ack2 (x y)
- (do () ((zerop x) (1+ y))
- (if (zerop y)
- (setf x (1- x)
- y 1)
- (psetf x (1- x)
- y (ack2 x (1- y))))))
- (defun ack3 (x y)
- (do ((x x (1- x))
- (y y (if (zerop y) 1 (ack3 x (1- y)))))
- ((zerop x) (1+ y))))
Add Comment
Please, Sign In to add comment