-- Solutions to CSE 341 Haskell Discussion Questions #1 -- Write a Haskell function to find the cube of a number. cube :: Double -> Double cube n = n^3 -- Write a Haskell function to find the sum of three Doubles sum3 :: Double -> Double -> Double -> Double sum3 x y z = x+y+z -- Write a Haskell function to find the value of the quadratic -- expression ax^2 + bx + c for parameters a, b, c, and x. quad_expr :: Double -> Double -> Double -> Double -> Double quad_expr a b c x = a*x^2 + b*x + c -- Write a Haskell function to reverse a list. my_rev :: [a] -> [a] my_rev [] = [] my_rev (x:xs) = my_rev xs ++ [x] -- here's a more efficient version that uses a helper function revappend my_rev2 :: [a] -> [a] my_rev2 s = revappend s [] -- reverse the first list, appending the second to the result revappend :: [a] -> [a] -> [a] revappend [] rest = rest revappend (x:xs) rest = revappend xs (x:rest) -- Write a function my_map2 that is analogous to map but works -- for functions of two arguments rather than one. my_map2 :: (a->b->c) -> [a] -> [b] -> [c] my_map2 f [] [] = [] my_map2 f (x:xs) (y:ys) = f x y : my_map2 f xs ys -- Suppose that the following Haskell script has been filed in ... my_const c x = c append [] ys = ys append (x:xs) ys = x : append xs ys my_map f [] = [] my_map f (x:xs) = f x : my_map f xs -- What is the result of evaluating the following Haskell expressions? -- Try them and see ...