Last active
March 3, 2016 09:28
-
-
Save terry3/8c91acbf044ef7e28fd6 to your computer and use it in GitHub Desktop.
The recursive implement of get n-th element in list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; The recursive implement of get n-th element in list | |
(defun get-n (x y) | |
(if (eql x 0) | |
(car y) | |
(get-n (- x 1) (cdr y)))) | |
(write-line (get-n 0 '("a" "b" "c" "d" "e"))) | |
(write-line (get-n 1 '("a" "b" "c" "d" "e"))) | |
(write-line (get-n 2 '("a" "b" "c" "d" "e"))) | |
(write-line (get-n 3 '("a" "b" "c" "d" "e"))) | |
(write-line (get-n 4 '("a" "b" "c" "d" "e"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment