Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List
- import Data.Typeable
- strToArr::String->[Double]
- strToArr line = [(read x::Double)| x<-(words line)]
- strToMatrix::String->[[Double]]
- strToMatrix mt = [(strToArr x)| x<-(lines mt)]
- arrToStr::[Double]->String
- arrToStr (h:t) = (read x::String) ++ " " ++ (arrToStr t)
- matrixToStr::[[Double]]->String
- matrixToStr [] = ""
- matrixToStr (h:t) = (arrToStr h) ++ "\n" ++ (matrixToStr t)
- main::IO()
- main = do
- arquivo <- readFile "teste.txt"
- print arquivo
- let matriz = (strToMatrix arquivo)
- print (typeOf matriz)
- writeFile "out.txt" (matrixToStr matriz)
Advertisement
Add Comment
Please, Sign In to add comment