2025-10-20 Daily Worksheet
Review
-
Inside a function
f x, useletto create variables x2 holding x squared, and x3 holding x cubed. Then create the function below.$$ f(x) = x^3 (x^2-1) $$
New
An official data type is Maybe a. The data definition is:
data Maybe a = Nothing | Just a
deriving (Show, Eq, ...)
-
Write a function
g2that takes in aMaybe Intand returns 0 if it is givenNothingand otherwise 10 more than the absolute value of the int.checks_2 = [ 0 == g2 Nothing , 12 == g2 (Just 2) , 25 == g2 (Just 15) ] -
Write a function that takes in a
Maybe Stringand puts out aMaybe String, doubling the string if it exists