Lecture Notes March 1 Roger Midmore When using Scheme you want to make sure it's set to full scheme. Otherwise you won't be abel to take advantage of all the features of the language. A good idea is to use this code for debugging (Require-Library "Trace.ss") (Trace Add1) (Untrace Add1) Handling Exceptions & Unexpected Errors --------------------------------------- (Define (*List O L) (cond ((null? L)1) ((= 0 (car L))0) (else (*(car L)(*List O (cdr L)))) In java exceptions are handled by throwing and catching exceptions ie. class zero extends throwable{} class prod{ static int mult(node L){ try{ return multnode(l); } catch(zero z){ return 0;} }} A continuation is a function that "compiles (continues with) a computation". The function is a delayed calculation. (define (*List L) (let ((v(call cc(lambda(x*here*)(*List L)))) (if(number? v) v (begin(display"enter substitute value for O") (newline) (v(Read)) )) (define (*List L return) (if (null? L) 1 (let loop((value (car L))) (if (= 0 value) (loop (call cc()) (lambda(x)(return x)))) (* value(*list (cdr L) return )) ))) ))) Lambda functions are used to capture the exection context of a function. You can return to that part in the code at a later time. You can also use it for exception handling by calling the exception when you need it. (delay expr)=>promise (force promise) (define (and A B) (if A B (force B) )) #f (define (infList I) (cons I (infList(+ I 1))) ) (define (infList2 I) (cons I (delay (infList2(+ I 1))) )) (infList 1)-> 1|delay infList2 2 (define head car) (define tail L) '(force(cdr L)) ) (head(tail L)) ------------------------------------------------- To use multiple processors in scheme you need to be able to split the problem into two seperate parts and run them on different processors.