99問目
http://projecteuler.net/index.php?section=problems&id=99
与えられた底と指数の組の中で一番大きいものはどれか求める。
cut-sea さんがSコンビネータについて書いてるのを見ながら色々試してて、flip f <*> g と f . g <*> id が等価だということが分かりました。(当たり前っちゃ当たり前なのですが、初めて id の使いみちを知ったもので‥)
--import Control.Applicative main = print . euler099 . map (read . ("(" ++) . (++ ")")) . lines =<< readFile "base_exp.txt" euler099 :: [(Int, Int)] -> Int euler099 base_exp = (+ 1) $ length $ takeWhile (< maximum logs) logs where logs = map (\ (a, b) -> (fromIntegral b) * log (fromIntegral a)) base_exp --euler099 = (+ 1) . length . (takeWhile . (>) . maximum <*> id) -- . map ((*) . fromIntegral . snd <*> log . fromIntegral . fst)