Re: [Haskell-cafe] List comparisons and permutation group code

2006-10-21 Thread Tomasz Zielonka
On Fri, Oct 20, 2006 at 06:08:26PM +0200, Henk-Jan van Tuyl wrote: How about this: import List isIdentity (PL xs) = xs `isPrefixOf` [1..] ? Great! This is so natural. When will I finally learn to continue thinking after finding the first solution, especially when I feel it's not ideal?!

Re: [Haskell-cafe] memory, garbage collection and other newbie's issues

2006-10-21 Thread Andrea Rossato
Hallo Bulat! On Fri, Oct 20, 2006 at 10:21:51PM +0400, Bulat Ziganshin wrote: first, GC don't occurs automatically when you close file. you can help GHC by using performGC from System.Mem. i does it in my own prog I did not get an appreciable improvement with performGC, as you can see from

Re: [Haskell-cafe] List comparisons and permutation group code

2006-10-21 Thread David House
On 21/10/06, Tomasz Zielonka [EMAIL PROTECTED] wrote: Do you also have this experience with Haskell?: when you feel that some code is not ideal, almost always it can be improved. One of the recurring features of the #haskell IRC conversations is something called 'Algorithm Golf' (which is a

Re: [Haskell-cafe] List comparisons and permutation group code

2006-10-21 Thread Donald Bruce Stewart
dmhouse: On 21/10/06, Tomasz Zielonka [EMAIL PROTECTED] wrote: Do you also have this experience with Haskell?: when you feel that some code is not ideal, almost always it can be improved. One of the recurring features of the #haskell IRC conversations is something called 'Algorithm Golf'

[Haskell-cafe] Best way to write endsWith

2006-10-21 Thread John Ky
Hello,I have this function here: endsWith :: Eq a = [a] - [a] - Bool endsWith suffix list | lengthDifference 0 = False | otherwise = (drop lengthDifference list) == suffix where lengthDifference = (length list) - (length suffix)Would this be the preferred function argument order? Or is the

[Haskell-cafe] Re: Best way to write endsWith

2006-10-21 Thread Stephan Walter
John Ky wrote: Hello, I have this function here: endsWith :: Eq a = [a] - [a] - Bool endsWith suffix list | lengthDifference 0 = False | otherwise = (drop lengthDifference list) == suffix where lengthDifference = (length list) - (length suffix) I thinks that's what

Re: [Haskell-cafe] Re: Best way to write endsWith

2006-10-21 Thread Lemmih
On 10/21/06, Stephan Walter [EMAIL PROTECTED] wrote: John Ky wrote: Hello, I have this function here: endsWith :: Eq a = [a] - [a] - Bool endsWith suffix list | lengthDifference 0 = False | otherwise = (drop lengthDifference list) == suffix where lengthDifference = (length list)

Re: [Haskell-cafe] Best way to write endsWith

2006-10-21 Thread Daniel Fischer
Hi John, long `endsWith` short = (reverse short) `isPrefixOf` (reverse long) would be a possibility (and might be slightly more efficient). And this argument order is much better according to the principle of least surprise (a `endsWith` b is naturally interpreted so that b is the suffix).

Re: [Haskell-cafe] memory, garbage collection and other newbie's issues

2006-10-21 Thread Udo Stenzel
Andrea Rossato wrote: I did not get an appreciable improvement with performGC, as you can see from here: http://gorgias.mine.nu/haskell/a.out.withPerformGC.ps But I found a solution: just write the opml state component to a file! Obviously the values in question were not garbage, rather

Re: [Haskell-cafe] memory, garbage collection and other newbie's issues

2006-10-21 Thread Andrea Rossato
Hallo! Thanks a lot for stopping by. On Sat, Oct 21, 2006 at 06:41:32PM +0200, Udo Stenzel wrote: The correct solution however, is the application of 'seq' at the right places. To understand where these are, perform a simulation of Haskell's reduction strategy on paper. I will definitely

Re: [Haskell-cafe] memory, garbage collection and other newbie's issues

2006-10-21 Thread Andrea Rossato
On Sat, Oct 21, 2006 at 09:09:13PM +0200, Andrea Rossato wrote: So, it's parsec, on your side...;-) I sorry, I was a bit confused when I wrote that. I confused you for another person, obviously. Sorry about that. Andrea pgpx3F8PsFdVW.pgp Description: PGP signature

Re[2]: [Haskell-cafe] memory, garbage collection and other newbie's issues

2006-10-21 Thread Bulat Ziganshin
Hello Andrea, Saturday, October 21, 2006, 3:44:31 PM, you wrote: first, GC don't occurs automatically when you close file. you can help GHC by using performGC from System.Mem. i does it in my own prog But I found a solution: just write the opml state component to a file! and just after that