-
-
Save LarynQi/3e92fd961b48f4c240d41047f8e21890 to your computer and use it in GitHub Desktop.
CS61A SU20 Discussion 10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Discussion 10 - Scheme | |
| ; Note: this file does not include doctests | |
| ; Q3.1 - WWSD | |
| (define a (+ 1 2)) | |
| ; ________________ | |
| a | |
| ; ________________ | |
| (define b (+ (* 3 3) (* 4 4))) | |
| ; ________________ | |
| (+ a b) | |
| ; ________________ | |
| (= (modulo 10 3) (quotient 5 3)) | |
| ; ________________ | |
| (even? (+ (- (* 5 4) 3) 2)) | |
| ; ________________ | |
| ; Q4.1 - WWSD | |
| (if (or #t (/ 1 0)) 1 (/ 1 0)) | |
| ; ________________ | |
| (if (> 4 3) (+ 1 2 3 4) (+ 3 4 (* 3 2))) | |
| ; ________________ | |
| ((if (< 4 3) + -) 4 100) | |
| ; ________________ | |
| (if 0 1 2) | |
| ; ________________ | |
| ; Q4.2 - factorial | |
| (define (factorial x) | |
| 'YOUR-CODE-HERE) | |
| ; Q4.3 - fib | |
| (define (fib n) | |
| 'YOUR-CODE-HERE) | |
| ; Q5.1 - my-append | |
| (define (my-append a b) | |
| YOUR-CODE-HERE) | |
| ; Q5.2 - insert | |
| (define (insert element lst index) | |
| YOUR-CODE-HERE) | |
| ; Q5.3 - duplicate | |
| (define (duplicate lst) | |
| YOUR-CODE-HERE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment