• Hi to all,
    i am a newbie in Haskell, and it has recently become my nightmare.. i have several years of programming experince, but i have never been stuck like this..
    please share your knowlodge, if you have any about my problem.. so here is my basic and first problem;
    i have a text file and lines in it, i need to get the contents of the file line by line to a list in my program..

    Then i will process the list in some way this is not the deal.. the big deal is how do i get the contents of the file line by line to a list !?
    i will appreciate any help.. Thanks..




    (Ich kann Deutsch nicht ganz erklären, deshalb musste ich Egnlisch geschrieben)

    [Blockierte Grafik: http://www.informatik-forum.at/pics/nb/statusicon/user_offline.gif]

  • Zitat von rose1000


    i have a text file and lines in it, i need to get the contents of the file line by line to a list in my program..

    Code
    main = do
      c <- getContents
      let ls0 = lines c
      let ls1 = map process_line ls0
      putStr (unlines ls1)
    
    
    process_line xs = drop 3 xs


    Now:

    $ cat txt
    1232652
    20aeusatheou
    3209625209856
    aoeu',l.cry,'rcg

    $ cat txt | runhugs test.hs
    2652
    eusatheou
    9625209856
    u',l.cry,'rcg

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!