Advertisement
flomath

seekMaxMin

Apr 28th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. maximum' [] = error "maximum of empty list"
  2. maximum' [x] = x
  3. maximum' (x:xs)
  4.        | x > current = x
  5.        | otherwise = current
  6.        where current = maximum' xs
  7.  
  8.        
  9. minimum' [] = error "minimum of empty list"
  10. minimum' [x] = x
  11. minimum' (x:xs)
  12.        | x < current = x
  13.        | otherwise = current
  14.        where current = minimum' xs
  15. {-
  16. Liste -> Tupel mit min max raus
  17.  
  18. -}
  19.  
  20.  
  21.  
  22.  
  23. seekMaxMin' [] = (0,0)
  24. seekMaxMin' [x] = (x,x)
  25. seekMaxMin' (x:xs) = (minimum' xs, maximum' xs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement