You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB
Haskell

#! /usr/bin/env runhaskell
type Ingredient = (String, Double, Double)
type Recette = ( String, [Ingredient], Double, Double)
ingredientsLessive :: [Ingredient]
ingredientsLessive = ( "Lessive"
, [ ("Eau", 0.003, 2.5)
, ("Savon de Marseille", 3.36, 0.1)
, ("Bicarbonate de soude", 3.81, 0.016)
, ("Vinaigre blanc", 0.36, 0.03)
]
, 2.5
, 30
)
quantiteLessive = 2.5
nombreUtilisations = 30
prixTotal ingredientsLessive = sum . map (\ (_, x, y) -> x * y) $ ingredientsLessive
prixLitre prixTotal quantiteLessive = prixTotal / quantiteLessive
prixUtilisation prixTotal quantiteLessive = prixTotal / nombreUtilisations
main = do
putStrLn "Calcul du coût des recettes\n"
putStrLn "* Lessive :"
print ingredientsLessive
putStrLn $ " * Prix Total = " ++ show prixTotal ++ ""
putStrLn $ " * Prix au litre = " ++ show prixLitre ++ ""
putStrLn $ " * Prix par utilisation = " ++ show prixUtilisation ++ ""