2025-10-20 Daily Worksheet
Review
-
Inside a function
f x
, uselet
to 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
g2
that takes in aMaybe Int
and returns 0 if it is givenNothing
and 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 String
and puts out aMaybe String
, doubling the string if it exists