Created
October 25, 2012 00:03
-
-
Save precious/3949711 to your computer and use it in GitHub Desktop.
funcs.lisp
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
(defun natural (a) | |
(and (integerp a) (> a 0)) | |
) | |
(defun fib (x) | |
(if (and (integerp x) (>= x 0)) | |
(if (< x 2) | |
1 | |
(+ (fib (- x 1)) (fib (- x 2))) | |
) | |
nil | |
) | |
) | |
(defun mygcd (a b) | |
(if (and (natural a) (natural b)) | |
(/ a (numerator (/ a b))) | |
nil | |
) | |
) | |
(defun mylcm (a b) | |
(if (and (natural a) (natural b)) | |
(/ (* a b) (mygcd a b)) | |
nil | |
) | |
) | |
(defun d2b (a) | |
(if (and (integerp a) (>= a 2)) | |
(append (d2b (floor a 2)) (list (mod a 2))) | |
(list a) | |
) | |
) | |
(defun myreverse (mylist) | |
(if (true-listp mylist) | |
(if (> (length mylist) 0) | |
(append (myreverse (cdr mylist)) (list (car mylist))) | |
'() | |
) | |
nil | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment