Reading and writing files in Haskell

So i've got two files with the following content:

File 1:
    Tom 965432145  
    Bill 932121234

File 2:
      Steve 923432323  
      Tom 933232323

and i want two merge this two files into one file, and write that out as 'out.txt'. i wrote this function to deal with duplicates (when the same name appears more than once, it choses what number goes into the final file).

the function is called choosing:

choosing :: [String] −> Int −> Int −> Int
choosing ("Name_of_person":_) num1 _ = num1 choosing _ num1 num2
        | num2 ‘div‘ 100000000 == 2 = num2
        | otherwise = num1

My idea was to read the files as tuples, like this:

[(name, phone number),(name,phone number)], so that becomes easier to compare each name and call the function to decide which number goes into the final file. Is this a good idea ? how can i do this ?

Answers


Need Your Help

Using Tiles with Spring MVC

java spring-mvc tiles

I'm just trying to Learn Tiles with Spring MVC. I haven't used Tiles Before. Please find the code attached:

Can I bundle a bundle of all javascript .js files?

javascript jsp jawr

On jsp page am including js bundles. And I need all of these bundles (.js files). Can I create a bundle of bundles in Jawr so that i can add single line? or should I create new bundle hand-pickin...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.