

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















March 1, 2007 Based on notes by N. Fisher, F. Hernandez-Campos, and D. Stotts
2
4
(define iter-fib (lambda (n) (do ((i 0 (+ i 1)) ; init 0 (a 0 b) ; init 0, set to b in each iter (b 1 (+ a b))) ; init 1, set to sub of a & b (display b) (display “ ”))))^ ((= i n) b) ;termination test and final value (iter-fib 10)
5
7
8
11
(+ 3 4) => 7 (quote (+ 3 4)) => (+ 3 4) ‘(+ 3 4) =>(+ 3 4)
(if (< 2 3) 4 5) => 4 (cond ((< 3 2) 1) ((< 4 3) 2) (else 3)) => 3
14
(let ((a 3) (b 4) (square (lambda (x) (* x x))) (plus +)) (sqrt (plus (square a) (square b)))) =>
16
(letrec ((fact (lambda (n) (if (= n 1) 1 (* n (fact (-n 1)))))) (fact 5))^ ;uses the “inner” fact
17
(car ‘(2 3 4)) => 2 (cdr ‘(2 3 4)) => (3 4) (cdr 2 ‘(3 4)) => (2 3 4) ;Returns the head ;Returns the tail ;Amend the List
20
(cons(define simulate^ (lambda (dfa (if (nul? (car dfa) input)^ input) (define move^ (simulate^ (if (infinal?^ (move^ dfa)dfa^ (car‘(accept)^ input))^ ‘(reject))^ (cdr^ input))))) (let^ (lambda (dfa (list (if (eq? ((curstate curstate^ symbol) (car dfa))‘error) (trans (cadr dfa)) (finals (caddr dfa)) (let ((pair trans^ ‘error (if pair (cadr (assoc pair) (list ‘error))) curstate sybol) trans))) finals))))