module Polynom where
data Person = Person
{ vorname :: String
, nachname :: String
} deriving Show
--vorname (Person a b) = a
--nachname (Person a b) = b
--first (a,b) = a
--second (a,b) = b
type Polynom = [Double]
--add xs ys = take (max (length xs) (length ys)) (zipWith (+) (xs ++ repeat 0) (ys ++ repeat 0))
--add xs ys
-- | length xs < length ys = zipWith (+) (xs ++ repeat 0) ys
-- | otherwise = zipWith (+) xs (ys ++ repeat 0)
--add [] ys = ys
--add xs [] = xs
add (x:xs) (y:ys) = x + y : add xs ys
add xs ys = xs ++ ys
eval :: Polynom -> Double -> Double
--eval ys x = foldr f 0 ys
eval ys x = foldr (\a b -> a + x * b) 0 ys
--eval ys x = foldr ((+) . (* x)) 0 ys
-- where f a b = a + x * b
deriv :: Polynom -> Polynom
deriv [] = []
deriv (x:xs) = zipWith (*) xs [1..]