Skip to content

Instantly share code, notes, and snippets.

@precious
Created October 25, 2012 00:03
Show Gist options
  • Save precious/3949711 to your computer and use it in GitHub Desktop.
Save precious/3949711 to your computer and use it in GitHub Desktop.
funcs.lisp
(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