fork download
  1. import Data.List (sortBy)
  2. import Data.Function
  3.  
  4. list :: [(String, Double -> Double)]
  5. list = [("2^n" , (2**))
  6. ,("2^log(n)" , (2**) . log)
  7. ,("4^n" , (4**))
  8. ,("n" , id)
  9. ,("n^2" , (^2))
  10. ,("n!" , product . enumFromTo 1)
  11. ,("n*log(n)" , (*) =<< log)
  12. ,("log(n!)" , log . product . enumFromTo 1)
  13. ,("log(log(n))" , log . log)
  14. ,("sqrt(log(n))" , sqrt . log)]
  15.  
  16. main :: IO ()
  17. main = mapM_ print $ reverse $ sortBy (compare `on` snd) $ map (fmap ($10)) list
  18.  
Success #stdin #stdout 0s 6292KB
stdin
Standard input is empty
stdout
("n!",3628800.0)
("4^n",1048576.0)
("2^n",1024.0)
("n^2",100.0)
("n*log(n)",23.025850929940457)
("log(n!)",15.104412573075516)
("n",10.0)
("2^log(n)",4.933409667914597)
("sqrt(log(n))",1.5174271293851465)
("log(log(n))",0.834032445247956)