KillianMills

exercise3.hs

Oct 23rd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type Poly = [Integer]
  2.  
  3. sumPoly :: Poly -> Poly -> Poly
  4. sumPoly xs [] = xs
  5. sumPoly [] ys = ys
  6. sumPoly (x:xs) (y:ys) = (x+y) : sumPoly xs ys
  7.  
  8. evalPoly :: Int -> [Int] -> Int
  9. evalPoly x [] = 0
  10. evalPoly a (x:xs) = x + a * (evalPoly a xs)
  11.  
  12.  
  13.  
  14. isPalindrome :: (Eq a) => [a] -> Bool
  15. isPalindrome x = x == (reverse x)
  16.  
  17.  
  18.  
  19. shortest :: [[a]] -> [a]
  20. shortest [] = []
  21. shortest [soleList] = soleList
  22. shortest (firstList : remainingLists) =
  23.     shortestOfTwo firstList (shortest remainingLists)
  24.  
  25. shortestOfTwo firstList secondList =
  26.     if length firstList < length secondList
  27.       then firstList
  28.       else secondList
Advertisement
Add Comment
Please, Sign In to add comment