[Solved] Summing the digits of a very large number [closed]


This would be a complete implementation in Haskell

import Data.List.Split (chunksOf)
import Data.List
import Data.Char (digitToInt)

main :: IO ()
main = do digits <- map digitToInt <$> readFile "pifile.txt"
          let summator = foldl1' (zipWith (+)) . chunksOf 4
          print $ summator digits

I will update this with some explanation later this day.

Update @Comments

main = do digits <- map digitToInt <$> readFile "pifile.txt"
              let summator = scanl1' (zipWith (+)) . chunksOf 4
              mapM_ print $ take 100 $ summator digits

5

solved Summing the digits of a very large number [closed]