2025-11-18 Review Practice
More review exercises covering the fundamentals. Originally from enrichment.
-
Make a data type
Cirto hold aPointcalledptand aDoublecalleddiam. This represents a circle with center pt and diameter diam. -
Make a data type
Gameto hold aStringcallednameand a list ofCircalledccc. -
Write a function that doubles the diameter and leaves the center unchanged.
larger :: Cir -> Cir -
Find the area of a circle with a given diameter.
area :: Cir -> Double -
Subtract 0.5 from each y coordinate in the Game.
lowerall :: Game -> Game -
Find the total area of all circles in the Game.
fullArea :: Game -> Double -
Two circles overlap if their radii add to more than the distance between their centers.
overlap :: Cir -> Cir -> Bool -
Find the first circle that overlaps one given circle. If there is no such circle, output
Nothing.touching :: Cir -> [Cir] -> Maybe Cir touching given circs = undefined -- fix- Recursion
- List comprehension plus something
- Higher order function (map, fold, filter)