Tutorial 2


Library file function definitions: Problems:
; for better formatting (than just print), use "format" ; can also be used for format conversion - check text



Problems with dotted pairs showing in append


; Recursion Examples
; generic form

(defun fn-name (args)
	(cond ((new-test x) base-case-return)
		(t ; otherwise recurse
			( .... (fn-name new-args) ...))))

; often test for base case is (null L) or (= 0 x)

; Factorial
; 
; fac(n) = n * fac(n-1)
; fac(0) = 1


; NB - it is possible to return multiple values
; from a function - see text
; (setq (x y z) (fn-call ...))

; Fibonacci
;
;fib(n) = fib(n-1) + fib(n-2)
;fib(1) = 1
; fib(2) = 2
; recursive call
; 	(t (+ (fib (- n 1)) (fib (- n 2)))


;CONDITIONALS