...
- Try calling some the built-in operations like
<=
,=
,and
,or
,not
,equal?
on various data values, e.g., is 17 times 18 bigger than 256? - What are the contracts of these built-in functions?
*Choose any two, and write down the contract.
*Verify your guess by asking the labby
or by using DrScheme's Help Desk to look at the
manual for the Beginning Student language.
*Practice writing a function which returns a Boolean:
Following the design recipe,
write
which takes in two numbersCode Block within-two?
m
andn
, and returns true if
m - n
and {{ n - m}} are both
less than2
.
Otherwise, it should return false.
(For learning purposes only, don't useabs
,
which computes the absolute value. Also, don't use
cond
orif
.)
Your examples/tests can look likeCode Block (boolean=?check-expect (within-two? 99.8 101) true) (boolean=?check-expect (within-two? 5 -5) false)
...