Hint on exercise from Real World Haskell

I have been working on the exercises from chapter 1 of Real World Haskell. I seem to be stuck on a solution to: 4.Modify the WC.hs example again, to print the number of characters in a file. I'm hoping to get a hint for this one. I may request a solution later but for now I would prefer just a hint. Regards Chris Saunders

When you read a file (System.IO.readFile, for example) its content is returned as a String... consider: type String = [Char] What function would you use to count the elements in a list? El lun, 28-06-2010 a las 22:45 -0400, Chris Saunders escribió:
I have been working on the exercises from chapter 1 of Real World Haskell. I seem to be stuck on a solution to:
4.Modify the WC.hs example again, to print the number of characters in a file.
I'm hoping to get a hint for this one. I may request a solution later but for now I would prefer just a hint.
Regards Chris Saunders
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Tuesday 29 June 2010 04:45:23, Chris Saunders wrote:
I have been working on the exercises from chapter 1 of Real World Haskell. I seem to be stuck on a solution to:
4.Modify the WC.hs example again, to print the number of characters in a file.
I'm hoping to get a hint for this one. I may request a solution later but for now I would prefer just a hint.
Have you done ex. 3: The words function counts the number of words in a string. Modify the WC.hs example to count the number of words in a file. ? Originally, WC uses lines to break a String into a list of lines. Then you use words to break a String into a list of words. Now you want to make a list of characters out of the String. How do you do that again?
Regards Chris Saunders

On Mon, 28 Jun 2010 22:45:23 -0400
"Chris Saunders"
print the number of characters in a file ... I'm hoping to get a hint for this one.
1. read in the file - which will be (eventually) a bunch of chars 2. count the chars by adding 1 to the count of the chars less one char (can be done with pattern matching x:xs and then using just xs) -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's
participants (4)
-
Chris Saunders
-
Daniel Fischer
-
MAN
-
prad