Thank you so much ! Luca and Bastian !
On 12/14/2010 12:32 PM, Sok H. Chang wrote:You're welcome! I am a beginner in haskell programming, it's interesting to work with others! By the way, this is the code:
Thank you so much, Luca.
Mmm... I want to make a "List of Sentence" from some text file.
inputFile.txt is like this.
--------------------------------
This is a pen.
Is this a pen?
etc...many sentence. Each line, only one sentence.
How can I make a list of sentence?
How can I declared inpStr?
Thank you.
Sincerely, Sok Chang
import Data.List
import System.IO
import System.Random
main :: IO ()
main = do
inh <- openFile "path_to_file" ReadMode
prova <- (mainloop inh [])
print prova
hClose inh
mainloop :: Handle -> [String] -> IO [String]
mainloop inh list = doreturn list
ineof <- hIsEOF inh
if ineof
thenmainloop inh (list ++ [inpStr])
else do
inpStr <- hGetLine inh
This is my version, it works I think.. I hope this helps you!!
Luca
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners