CS SE 304 call/cc quiz Day 33. Name______________________
1. Show the output when the following expressions are executed in the order shown
Copyright By PowCoder代写 加微信 powcoder
> (define xxx -)
> (* 7 (call/cc (lambda (k)
(set! xxx k)
(+ 3 (k 4))))) ; output: ___________
> (+ 5 (xxx (xxx 2))) ; output ____________
2. Show the output when the following code is executed:
(call/cc list?) ; output: ___________
3. We examined the following code in class on Thursday.
It returns the position of sym in L, and returns -1 if sym is not in L.
(define list-index
(lambda (sym L)
(lambda (answer)
(let loop ([L L])
(cond [(null? L) (answer -1)]
[(eqv? sym (car L)) 0]
[else (+ 1
(loop (cdr L)))]))))))
What would go wrong if we replaced (answer -1) by -1?
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com