content: -- TP sur foldr et foldl
  
  -- Exemple sur la somme d'une liste d'entier
  mySum :: [Int] -> Int
  mySum ls = foldl (\acc elem -> acc + elem) 0 ls
  
  -- Version foldr
  mySumR :: [Int] -> Int
  mySumR ls = foldr (\elem acc -> elem + acc) 0 ls
  
  -- Exercice 1
  -- ilExiste
  ilExiste :: (a -> Bool) -> [a] -> Bool
  ilExiste f ls = foldl (\acc elem -> acc || f elem) False ls
  
  pourTout :: (a -> Bool) -> [a] -> Bool
  pourTout f ls = foldl (\acc elem -> acc && f elem) True ls
  
  -- Exercice 2
  concatF :: [[a]] -> [a]
  concatF ls = foldr (\elem acc -> elem ++ acc) [] ls
  
  length1 :: [a] -> Float
  length1 ls = foldr (\_ acc -> acc + 1) 0 ls
  
  -- Exercice 3
  
  parenthèseOkF :: String -> Bool
  parenthèseOkF str = snd (foldl f (0, True) str)
      where f (nbParOuverte, parOk) element
              | element == '(' = (nbParOuverte + 1, parOk)
              | element == ')' && nbParOuverte > 0 = (nbParOuverte - 1, nbParOuverte == 1)
              | element == ')' && nbParOuverte == 0 = (nbParOuverte, False)
              | otherwise = (nbParOuverte, parOk)
  
  -- Exercice 4
  factorielle :: (Num b, Enum b) => b -> b
  factorielle i = foldl (*) 1 [2..i]
  
  -- Exercice 5
  repetF :: Int -> a -> [a]
  repetF i a = foldr (\_ acc -> a:acc) [] [1..i]
  
  -- Exercice 6
  mean :: [Float] -> Float
  mean ls = foldl (\acc elem -> acc + m elem (length1 ls)) 0 ls
      where m a n = (a / n)