[Solved] Haskell, tuple (double, string) [closed]


You can implement it using mapM_/traverse_ or the flipped argument versions: forM_/for_. I prefer for_ since it looks more like the “enhanced for-loop” from languages like Java.

import Data.Foldable (for_)

myPutStr :: [(Double,String)] -> IO ()
myPutStr vals = do
    for_ vals $ \(num, str) -> do
        putStr str
        putStr ": "
        print (num * 1.15) -- increase num by 15%
    putStrLn "Done"

solved Haskell, tuple (double, string) [closed]