8.10

Homework 1b

home work!

Programming Language #lang htdp/bsl

Due Date Thu at 9:00pm (Week 1)

Purpose To practice basic writing basic functions & tests.

MAKE SURE YOU INCLUDE TESTS FOR ALL OF YOUR FUNCTIONS.

Submit all of the following in a single .rkt file to Gradescope You will get immediate feedback and can resubmit.

Exercises

Exercise 1 Define a function "dist" that consumes two numbers, x and y, and that computes the distance of point (x,y) to the origin.

Exercise 2 Define "iff". The function consumes two Boolean values, call them "happy" and "outside". Its answer is "#true" if "happy" and "outside" are both true or both false, and "#false" otherwise. This Boolean operation, short for if and only if, is an equivalence, and logicians often use the notation happy <=> outside for this purpose.

Exercise 3 Define the function "image-classify", which consumes an image and conditionally produces "tall" if the image is taller than wide, "wide" if it is wider than tall, or "square" if its width and height are the same.

Exercise 4 Define the function "image-area", which counts the number of pixels in a given image.