Challenge 2: Odd Squares — Comprehension vs. filter/map — Possible Solution ==================================================================== Main.hs: oddSquaresComprehension :: [Int] oddSquaresComprehension = [x * x | x <- [1..20], odd x] oddSquaresFilterMap :: [Int] oddSquaresFilterMap = map (\x -> x * x) (filter odd [1..20]) main :: IO () main = do print oddSquaresComprehension print oddSquaresFilterMap print (oddSquaresComprehension == oddSquaresFilterMap) Output: [1,9,25,49,81,121,169,225,289,361] [1,9,25,49,81,121,169,225,289,361] True Explanation: The comprehension [x * x | x <- [1..20], odd x] reads as "x squared, for every x drawn from 1 to 20, where x is odd" -- generator first, then a filtering condition. The filter/map version expresses the identical logic in two separate steps: filter odd [1..20] first keeps only the odd numbers, then map (\x -> x * x) squares each surviving one. Both approaches produce byte-for-byte identical results, since a list comprehension with a condition is, underneath, just sugar over exactly this filter-then-map shape. WHY THIS WORKS AS AN ANSWER ------------------------------ This writes the same transformation two ways -- comprehension syntax and explicit filter/map -- and confirms with a direct equality check that they produce identical results, demonstrating comprehensions are genuinely equivalent to, not different from, filter/map composition.