[Haskell-cafe] Solution to Thompson's Exercise 4.4

Sean Perry shaleh at speakeasy.net
Sat Mar 12 04:27:58 EST 2005


Andy Georges wrote:
> Hi Kaoru,
> 
> 
>>I have been working through the exercises in Thompson's The Craft of
>>Functional Programming 2nd Ed book. I am looking for a solution web
>>site for Thompson's book. Or maybe the people here can help.
>>
>>In exercise 4.4, I am asked to define a function
>>
>> howManyOfFourEqual :: Int -> Int -> Int -> Int -> Int
>>
>>which returns the number of integers that are equal to each other. For
>>example,
>>
>> howManyOfFourEqual 1 1 1 1 = 4
>> howManyOfFourEqual 1 2 3 1 = 2
>> howManyOfFourEqual 1 2 3 4 = 0
> 
> 
> A solution which is applicable to any number of arguments is this:
> 

when this example occurs in the text the new Haskell coder has not been 
introduced to most of what you suggest.

Some of the exercises I felt were meant to be a little painful so that 
when you were introduced to a new concept a chapter or two later you 
would think "oh, that would have made X.Y so much easier".


More information about the Haskell-Cafe mailing list