Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun kth-to-last-recursive (l k)
- (let ((i 0))
- (labels ((helper (l)
- (unless (null l)
- (let ((head (helper (rest l))))
- (incf i)
- (if (= i k)
- ;; how to return this and be done with recursion?
- (car l)
- head)))))
- (helper l))))
- (= 5 (kth-to-last-recursive '(1 2 3 4 5) 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement