• # HS

    Posté par . En réponse au message PROBLEME AVEC LA COMMANDE AWK. Évalué à 1. Dernière modification le 05 septembre 2014 à 18:20.

    Je suis complètement hors sujet, mais comme j'apprends le haskell en ce moment je m'entraîne :

    import Control.Applicative
    import qualified Data.Map as Map
    import Data.List
    main = do
     contents <- (Map.toList . Map.fromListWith (+) . map (myRead . words) . lines) <$> readFile "y.txt"
     putStrLn . concat . intersperse "\n" . map (\(x,y) -> x ++ " " ++ show y) $ contents 
     where myRead [a, b] = (a, (read b)::Int)