TPK algorithm: Difference between revisions

Content deleted Content added
Yobot (talk | contribs)
m WP:CHECKWIKI error fixes - Replaced endash with hyphen in sortkey per WP:MCSTJR using AWB (9100)
Haskell: Unnecessary overengineering fixed.
Line 115:
<source lang="haskell">
import Control.Monad
f x = mfilter (<=400) $ Just $ sqrt (abs x) + 5 * x ^ 3
message x = if x > 400 then "TOO LARGE" else show x
main :: IO ()
main = replicateM 11 $ getLine >>= putStrLn . message . read
main = mapM_ (maybe (putStrLn "TOO LARGE") print.f.read) . reverse =<< replicateM 11 getLine
 
f :: Double -> Maybe Double
f x = mfilter (<=400) $ Just $ sqrt (abs x) + 5*x^3
</source>
Haskell uses monads for input/output. andIteration theis Maybereplaced databy typerecursion toin signalthe overflowlanguage.
 
===[[Java_(programming_language)|Java 5]]===