Manioc

estapora

Oct 23rd, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.List
  2. import Data.Typeable
  3.  
  4. strToArr::String->[Double]
  5. strToArr line = [(read x::Double)| x<-(words line)]
  6.  
  7. strToMatrix::String->[[Double]]
  8. strToMatrix mt = [(strToArr x)| x<-(lines mt)]
  9.  
  10. arrToStr::[Double]->String
  11. arrToStr (h:t) = (read x::String) ++ " " ++ (arrToStr t)
  12.  
  13. matrixToStr::[[Double]]->String
  14. matrixToStr [] = ""
  15. matrixToStr (h:t) = (arrToStr h) ++ "\n" ++ (matrixToStr t)
  16.  
  17. main::IO()
  18. main = do
  19.     arquivo <- readFile "teste.txt"
  20.     print arquivo
  21.     let matriz = (strToMatrix arquivo)
  22.     print (typeOf matriz)
  23.     writeFile "out.txt" (matrixToStr matriz)
Advertisement
Add Comment
Please, Sign In to add comment