Due: Friday 09/20 10:00am
Submission name: work07.rkt
Chapter 5 covers boolean values and operators.
Write contracts and the functions for the following:
Use define
and lambda
to write your functions. Include test cases with descriptive output.
isBetween
- Takes 3 numbers as inputs (let’s call them a, b and c)
- Returns:
true
if a is greater than b and a is less than cfalse
in all other cases
- Examples:
(isBetween 5 4 6) ==> true (isBetween 3 7 9) ==> false (isBetween 4 4 9) ==> false
pythTriple
- Takes 3 numbers as inputs (let’s call them a, b and c)
- Returns:
true
if the three inputs could be the sides of a right triangle, with the last parameter being the hypotenusefalse
in all other cases
- Examples:
(pythTriple 3 4 5) ==> true (pythTriple 6 7 10) ==> false (pythTriple 4 3 5) ==> true (pythTriple 5 3 4) ==> false
pythTriple2
- Takes 3 numbers as inputs (let’s call them a, b and c)
- Returns:
true
if the three inputs could be the sides of a right triangle, where any of the sides could be the hypotenusefalse
in all other cases- Examples:
(pythTriple2 3 4 5) ==> #true (pythTriple2 6 7 10) ==> #false (pythTriple2 4 3 5) ==> #true (pythTriple2 5 3 4) ==> #true (pythTriple2 4 5 3) ==> #true
exor
- This is known as the exclusive or operator
- Takes 2 boolean values as inputs
- Returns:
true
if exactly one of the 2 inputs is truefalse
in all other cases- Examples:
(exor #true #true) ==> false (exor #true #false) ==> true (exor #false #true) ==> true (exor #false #false) ==> false (exor (> 3 4) (<= 5 6)) ==> true