Re: [Haskell-cafe] hFileSize vs length

2005-03-12 Thread Gracjan Polak
S. Alexander Jacobson wrote: I am using GHC 6.2 on windows and am finding that when I open a file and use hFileSize I get a different number than I get from reading in the file and calculating the length. I assume this is not a bug, but I don't know why its happening. Isn't that because of

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

2005-03-12 Thread Sean Perry
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

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

2005-03-12 Thread Gour
Kaoru Hosokawa ([EMAIL PROTECTED]) wrote: I hope to find a better solution. I googled but couldn't find the answer. Here is what I have. I do not have working Haskell interpreter at the moment (being on amd64), but this is what I have in my archive: weakAscendingOrder :: Int - Int - Int -

Re: [Haskell-cafe] Parity of the number of inversions of a permutation

2005-03-12 Thread Henning Thielemann
On Fri, 11 Mar 2005, William Lee Irwin III wrote: On Wed, Mar 09, 2005 at 12:42:09PM +0100, Henning Thielemann wrote: I'm searching for a function which sorts the numbers and determines the parity of the number of inversions. I assume that there are elegant and fast algorithms for this problem (n

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

2005-03-12 Thread Mark Carroll
I had a go with things along this theme and came up with a couple of options, with different type signatures. I use some functions from the Data.List library. If we know that, as with Ints, we are dealing with list members that are instances of Ord, we can do: howManyEqual :: (Eq a, Ord a) = [a]

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

2005-03-12 Thread Andy Georges
Hi all, when this example occurs in the text the new Haskell coder has not been introduced to most of what you suggest. I didn't realise that. All apologies. mvg, Andy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] RE: Newbern's Example 7

2005-03-12 Thread Alson Kemp
Jeff, Thank you for your reply. After fn is lifted, where is bind used in allCombinations? The bind happens inside the liftM2 function, which can be defined as (taken from http://www.haskell.org/onlinereport/monad.html): liftM2 f = \a b - do { a' - a; b' - b; return (f a' b') } Using the

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

2005-03-12 Thread Kaoru Hosokawa
Thanks to all the replies! It seems that there are ways to solve the exercise if I use constructs that are found in later chapters of the book. Sean could be right in that some of the exercises are meant to be difficult to solve and they prepare you for later chapters. Tried Gour's suggestion,

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

2005-03-12 Thread Sean Perry
Kaoru Hosokawa wrote: Thanks to all the replies! It seems that there are ways to solve the exercise if I use constructs that are found in later chapters of the book. Sean could be right in that some of the exercises are meant to be difficult to solve and they prepare you for later chapters. As a

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

2005-03-12 Thread Michael Vanier
Date: Sat, 12 Mar 2005 23:39:21 -0800 From: Sean Perry [EMAIL PROTECTED] Cc: Haskell-Cafe@haskell.org As an aside, I kept all of the exercises in revision control. So I can look back at what I first wrote and my later changes. A habit I plan to keep as I move on to other programming