Skip to content

Instantly share code, notes, and snippets.

@LarynQi
Created Jul 28, 2020
Embed
What would you like to do?
CS61A SU20 Discussion 10
; 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