Posted: Fri Sep 19
Due: Monday 9/22 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:
trueif a is greater than b and a is less than cfalsein 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:
trueif the three inputs could be the sides of a right triangle, with the last parameter being the hypotenusefalsein 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:
trueif the three inputs could be the sides of a right triangle, where any of the sides could be the hypotenusefalsein 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:
trueif exactly one of the 2 inputs is truefalsein 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