Added lisp along with some study work

This commit is contained in:
2017-06-23 02:16:42 -07:00
parent 0523d93916
commit 0d49347cb7
10 changed files with 496 additions and 0 deletions

View File

@ -0,0 +1,26 @@
;; Take a positive int and print that many dots
;; repetition
(defun print-dots(num-of-dots)
(do ((i 0 (+ i 1)))
((= i num-of-dots) 'done)
(format t ". ")))
;; recursion
(defun print-dots-rec(num-of-dots)
;plusp checks if it's a positivie integer above 0.0
(if (plusp num-of-dots)
(progn
(format t ". ")
(print-dots-rec(- num-of-dots 1)))))
;; Take a list and return the number of times the symbol "a" occurs in it
(defun count-a-symbols(lst)
(do ((new-lst lst (cdr new-lst))
(n 0 (+ n (if (eq (car new-lst) 'a) 1 0))))
((not new-lst) n)))
;; Now do a recursive version (which is probably easier)
(defun count-a-symbols-rec(lst)
(if lst
(+ (if (eq (car lst) 'a)1 0) (count-a-symbols-rec(cdr lst)))
1))