Audio tutorial demoKurt Nørmark
Department of Computer Science, Aalborg University, Denmark
Program: The fac function. This is the classical recursive edition of fac.
  |  | ;; Calculate the factorial of n.
;; .parameter n An integer
;; .pre-condition The integer must be non-negative.
;; .returns n!
(define (fac n)
  (if (= 0 n) 1 (* n (fac (- n 1)))))  |  
  | 
Program: The fib function. This is the classical recursive edition of fib, which is very time consuming.
  |  | (define (fib n)
  (cond ((or (= n 0) (= n 1)) 1)
        (else (+ (fib (- n 1)) (fib (- n 2)))))) |  
  | 
 Audio tutorial demo
Course home     Author home     About producing this web     Previous lecture (top)     Next lecture (top)     Previous lecture (bund)     Next lecture (bund)     
Generated: November 14, 2011, 09:22:41