Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-maxmin list = if null (tail list)
  2.         then (head list, head list)
  3.         else (  if (head list) > fst (maxmin (tail list))
  4.             then head list
  5.             else fst (maxmin (tail list))
  6.              ,  if (head list) < snd (maxmin (tail list))
  7.             then head list
  8.             else snd (maxmin (tail list))
  9.              )-}
  10.  
  11. maxmin list =   let h = head list
  12.         in if null (tail list)
  13.            then (h, h)
  14.            else ( if h > t_max then h else t_max
  15.             , if h < t_min then h else t_min)
  16.             where t = maxmin (tail list)
  17.                   t_max = fst t
  18.                   t_min = snd t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement