


























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!



























Com S 342
Com S 342
Com S 342
Com S 342
Com S 342
q list->vector^
soup +^
V17a <=?^
a34kTMNs the-word-recursion-has-many-meanings Any identifier may be used as a variable or as a syntactic keyword. When an identifier appears as a literal or within a literal, it is being used todenote a symbol, that is, equality (eqv?) is defined for identifiers.
Com S 342
pair? symbol?^
number? char?^
string? vector?^
port? procedure? These predicates define the types
Com S 342
Examples:^
> (+ 3 4) 7 > ((if #f + *) 3 4) 12 ^ Scheme uses the call-by-value parameter passing mechanism; everyargument is evaluated, including the expression that denotes the procedure,before the procedure is called.
Com S 342
Com S 342
Com S 342
(set! ) Example:^
> (define x 2)> (+ x 1) 3 > (set! x 4)> (+ x 1) 5 Note: must be bound either in some enclosing region (as in theexample) or at top level (in the program).
Com S 342
(begin {}+ ) ^ Iteration:
(do ( {( )}
( {}
{}
^ Binding:^
(let ({}
+^ ) ) ::= ( )
Com S 342
; procedure bubble-sort (lambda (lon)
; procedure with one argument (if (null? lon)
; test whether list is empty `()^
; if list is empty, we are done ; set variable lon-with-elem-left(let ((lon-with-max-elem-left (reverse (put-max-last lon)))); build sorted list using recursion(cons (car lon-with-max-elem-left) ; select head of lon-with-max-elem-left; apply bubble-sort to the tail of lon-with-max-elem-left(bubble-sort (cdr lon-with-max-elem-left))))) ; end if) ; end lambda) ; end define