2025-10-20 Daily Worksheet

Review

  1. Inside a function f x, use let 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, ...)
  1. Write a function g2 that takes in a Maybe Int and returns 0 if it is given Nothing and otherwise 10 more than the absolute value of the int.

      checks_2 = [   0 == g2 Nothing
                  , 12 == g2 (Just 2)
                  , 25 == g2 (Just 15) ]
    
  2. Write a function that takes in a Maybe String and puts out a Maybe String, doubling the string if it exists