Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; =============== Q3 a) ===============
- (check-expect (absolutely-odd (cons -10 (cons 22 (cons 43 empty)))) 43)
- (check-expect (absolutely-odd (cons -13 (cons 3 (cons 7 empty)))) 23)
- (check-expect (absolutely-odd (cons 11 (cons -6 (cons 2 empty)))) 11)
- (check-expect (absolutely-odd (cons -7 (cons 2 (cons 5 empty)))) 12)
- (check-expect (absolutely-odd (cons 0 (cons 176489 (cons -997789 empty))))
- 1174278)
- (check-expect (absolutely-odd (cons 4876 (cons -238762 (cons 11 empty))))
- 11)
- (check-expect (absolutely-odd (cons -123421 (cons 332233 empty))) 455654)
- (check-expect (absolutely-odd (cons 3 (cons -7 (cons 1 (cons 8 empty))))) 11)
- (check-expect (absolutely-odd (cons 12 (cons 22 (cons 8 empty)))) 0)
- (check-expect (absolutely-odd empty) 0)
- (check-expect (absolutely-odd
- (cons -223
- (cons 12345
- (cons 6 (cons -123421 (cons 123 empty))))))
- 136112)
- (check-expect (absolutely-odd (cons 0 (cons 0 (cons 0 empty)))) 0)
- ;; =============== Q3 b) ===============
- (check-expect
- (spiraling? (cons 100 (cons -1000 (cons -10000 empty))))
- false)
- (check-expect
- (spiraling? (cons 1 (cons -324 (cons 30000 empty))))
- true)
- (check-expect
- (spiraling? (cons 23 (cons -142 (cons 0 empty))))
- false)
- (check-expect
- (spiraling? (cons 54 (cons 100 (cons 240 empty))))
- false)
- (check-expect
- (spiraling? (cons -1 (cons 24 (cons -10000 empty))))
- true)
- (check-expect
- (spiraling? (cons 0 (cons -10 (cons 100 empty))))
- false)
- (check-expect
- (spiraling? (cons 100 (cons -10 (cons 1 empty))))
- false)
- (check-expect
- (spiraling? (cons 3 (cons 2 (cons -1 empty))))
- false)
- (check-expect
- (spiraling? (cons 123454 (cons -1012345 (cons 12456124 empty))))
- true)
- (check-expect
- (spiraling? (cons 1 empty))
- true)
- (check-expect
- (spiraling? empty)
- true)
- ;; =============== Q3 c) ===============
- (check-within
- (geometric-mean (cons 14(cons 0.2 (cons 45 empty))))
- 5.0133 0.0001)
- (check-within
- (geometric-mean (cons 123 (cons 425 (cons 0.41 empty))))
- 27.7774 0.0001)
- (check-within
- (geometric-mean (cons 55 (cons 212 (cons 4 empty))))
- 35.9959 0.0001)
- (check-within
- (geometric-mean (cons 132 (cons 23 (cons 6.23 empty))))
- 26.6438 0.0001)
- (check-within
- (geometric-mean (cons 2.5 (cons 14.2 (cons 46.2 empty))))
- 11.7929 0.0001)
- (check-within
- (geometric-mean (cons 123 (cons 2.5 (cons 0.01 empty))))
- 1.4541 0.0001)
- (check-within
- (geometric-mean (cons 5.4 (cons 21 (cons 55.2 empty))))
- 18.4296 0.0001)
- (check-within
- (geometric-mean (cons 98 (cons 25.1 (cons 1.1 empty))))
- 13.9346 0.0001)
- (check-within
- (geometric-mean (cons 1 empty))
- 1 0.0001)
- (check-within
- (geometric-mean (cons 9 (cons 0.5 empty)))
- 2.1213 0.0001)
- ;; ================ Q4 a) ================
- (check-expect
- (rainbow? (cons 'orange (cons 'yellow (cons 'violet empty))))
- true)
- (check-expect
- (rainbow? (cons 'cars (cons 'planes (cons 'train empty))))
- false)
- (check-expect
- (rainbow? (cons 'blue (cons 'indigo (cons 'violet empty))))
- true)
- (check-expect
- (rainbow? (cons 'red empty))
- true)
- (check-expect
- (rainbow? (cons 'orange (cons 'green empty)))
- true)
- (check-expect
- (rainbow? (cons 'red (cons 'red (cons 'red empty))))
- false)
- (check-expect
- (rainbow? empty)
- true)
- ;; ================ Q4 b) ================
- (check-expect
- (unicorn 'green (cons 'red (cons 'green (cons 'blue empty))))
- (cons 'red (cons 'blue empty)))
- (check-expect
- (unicorn 'orange (cons 'red (cons 'green (cons 'violet empty))))
- (cons 'red (cons 'green (cons 'violet empty))))
- (check-expect
- (unicorn 'red (cons 'red (cons 'yellow (cons 'blue empty))))
- (cons 'yellow (cons 'blue empty)))
- (check-expect
- (unicorn 'green (cons 'green empty)) empty)
- (check-expect
- (unicorn 'blue empty) empty)
- (check-expect
- (unicorn 'yellow (cons 'red
- (cons 'orange
- (cons 'yellow (cons 'green (cons 'blue empty))))))
- (cons 'red (cons 'orange (cons 'green (cons 'blue empty)))))
- ;; ================ Q4 c) ================
- (check-expect
- (leprechaun 'red (cons 'yellow (cons 'blue empty)))
- (cons 'red (cons 'yellow (cons 'blue empty))))
- (check-expect
- (leprechaun 'green (cons 'red (cons 'yellow (cons 'blue empty))))
- (cons 'red (cons 'yellow (cons 'green (cons 'blue empty)))))
- (check-expect
- (leprechaun 'orange (cons 'orange (cons 'yellow (cons 'violet empty))))
- (cons 'orange (cons 'yellow (cons 'violet empty))))
- (check-expect
- (leprechaun 'yellow (cons 'red (cons 'green (cons 'blue empty))))
- (cons 'red (cons 'yellow (cons 'green (cons 'blue empty)))))
- (check-expect
- (leprechaun 'violet (cons 'yellow (cons 'blue empty)))
- (cons 'yellow (cons 'blue (cons 'violet empty))))
- (check-expect
- (leprechaun 'violet (cons 'blue empty))
- (cons 'blue (cons 'violet empty)))
- (check-expect
- (leprechaun 'orange empty)
- (cons 'orange empty))
- (check-expect
- (leprechaun 'indigo (cons 'red
- (cons 'yellow (cons 'blue (cons 'violet empty)))))
- (cons 'red (cons 'yellow (cons 'blue (cons 'indigo (cons 'violet empty))))))
- (check-expect
- (leprechaun 'violet (cons 'red empty))
- (cons 'red (cons 'violet empty)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement