Complete exercises 1 - 3 for Monday 3/4.
1. Write (between? n a b) that checks if n is between a and b.
Do not assume a < b.
;; Number Number Number -> Boolean
;
(define between?
(lambda (n a b)
;; Test cases
(between? 1 0 5) -> true
(between? 1 5 0) -> true
(between? 0 0 3) -> true
(between? -3 4 -3) -> true
(between? 10 -5 5) -> false
2. Given the predicate function:
;; Integer Integer -> Boolean
; Assume d is not 0.
(define divisor?
(lambda (n d)
(zero? (remainder n d))))
If a use writes (divisor? 12 0) the result is a divison by
0 error.
Modify divisor? so that if d is 0 the
function results in false instead of a divison by zero error.
ex. (divisor? 12 3) -> true
(divisor? 22 0) -> false
2. Write the function (leap-year? year) that takes a year and returns
true if the year is a leap year; false otherwise. Rules to determine a
leap year are as follows:
Any year that is divisible by 400 is a leap year.
All other leap years fall on years divisible by 4 and not by 100.
For further information check out this link:
https://www.wwu.edu/skywise/leapyear.html
For example,
(leap-year? 2000) -> true
(leap-year? 2004) -> true
(leap-year? 2100) -> false
(leap-year? 2017) -> false
You may use the functions (divisor? n d) and (xor a b) in your solution.