Created
June 27, 2017 20:41
-
-
Save honix/38072b47dd67fb470f790ff206976918 to your computer and use it in GitHub Desktop.
Ninety-Nine Lisp Problems
This file contains 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
;; http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html | |
;; | |
;; trying to use only these sacred symbols | |
;; (quote, atom, eq, car, cdr, cons and cond) | |
(defvar s '(a b c d)) | |
(defun my-last (l) | |
(if (cdr l) | |
(my-last (cdr l)) | |
l)) | |
(defun my-but-last (l) | |
(if (cddr l) | |
(my-but-last (cdr l)) | |
l)) | |
(defun my-nth (l i) | |
(if (= i 0) | |
(car l) | |
(my-nth (cdr l) (- i 1)))) | |
(defun my-length (l) | |
(if (null l) | |
0 | |
(+ 1 (my-length (cdr l))))) | |
(defun my-reverse (l) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment