Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.Foldable
  2.  
  3. maxSquare :: (Ord a, Num a) => [(a -> a)] -> (a -> a)
  4. maxSquare funcs = helper
  5.     where helper x = snd $ maximumBy getMax (map makeTuples funcs)
  6.             where makeTuples f = (f x * f x, f x)
  7.                   getMax a b = compare (fst a) (fst b)
  8.  
  9.  
  10. -- maxSquare :: (Ord a, Num a) => [(a -> a)] -> (a -> a)
  11. -- maxSquare funcs = helper
  12. --     where helper x = sqrt $ maximum (map getSquared funcs)
  13. --           where getSquared f = f x * f x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement