• + 0 comments

    In Haskell, map (flip filter list) on a list of predicates is kinda neat.

    import Text.Printf
    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)]