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

Binary file not shown.

View File

@ -0,0 +1,23 @@
(defparameter *small* 1)
(defparameter *big* 100)
(defun guess-my-number ()
;; ash is the artithmetic shift function
;; Halvs the sum of the limits and shortens the result
;; ash, here, shifts the binary bits left or right (well, right in this case)
;; Which leads to the right most binary falling off
;; This is a binary search
(ash (+ *small* *big*) -1))
(defun smaller ()
(setf *big* (1- (guess-my-number)))
(guess-my-number))
(defun bigger ()
(setf *small* (1+ (guess-my-number)))
(guess-my-number))
(defun start-over ()
(defparameter *small* 1)
(defparameter *big* 100)
(guess-my-number))

View File

@ -0,0 +1,30 @@
;; List of variables that are surrounded by parens
(let ((a 5)
(b 6))
(+ a b))
;; Local functions
;; It's like let. A list of functions and their descriptions,
;; followed by some stuff to do with them
(flet ((function_name (args)
...Function Body...))
body)
;;example
(flet ((f (n)
(+ n 10)))
(f 5))
>> 15
;; labels -- like flet, but allow functions to call other
;; defined functions or themselves
;; Same basic structure as flet
(labels ((a (n)
(+ n 5))
(b (n)
(+ (a n) 6)))
(b 10))
>> 21