You are viewing a single comment's thread. Return to all comments →
In Haskell, map (flip filter list) on a list of predicates is kinda neat.
map (flip filter list)
import Data.List (genericLength)
main = do
len <- readLn :: IO Float
list <- fmap (map (read :: String -> Int) . words) getLine
mapM_ (printf "%.6f\n" . (/len) . genericLength . flip filter list) [(>0), (<0), (==0)]