CS152
Chris Pollett
Apr. 13, 2009
((lambda (x) (* x x)) 3) ; gives 9
(define compose (lambda (f g) (lambda (x) (g (f x)))))
(define make-new-balance (lambda (balance)
(lambda (amount)
(if (< balance amount) "insufficient funds"
(begin
(set! balance (- balance amount))
balance)))))
(define atm (make-new-balance 100))
(atm 20)
; returns 80
(define my-class (lambda (construct-arg1 ...)
(let ((my-field1 val1) ; it is also legal to nest define's in Scheme
(my-field2 val2) ...)
(lambda (msg . args)
(cond ((eqv? msg msg1)
;do-some-action
)...
))))
(define my-instance (my-class construct-val1 ...))
(my-instance msg1 msg1-args)
Which of the following would be evaluated in applicative order?
(string->symbol "hi") outputs hi symbol (symbol->string 'hi) outpus "hi" string