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

2006-10-19 Thread Tomasz Zielonka
On Thu, Oct 19, 2006 at 04:03:38PM +0200, Mikael Johansson wrote: > isIdentity (PL xs) = all (\(i,j) -> i==j) (zip [1..] xs) > > isIdentity (PL xs) = xs == [1..(length xs)] How about a compromise? isIdentity (PL xs) = xs == zipWith const [1..] xs Best regards Tomasz

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

2006-10-19 Thread Nicolas Frisby
It's nice to have that pointed out; I'm always forgeting that there's a representation optimization going on when using Ints/Integers for naturals. This Peano approach makes the length check no longer strict in the spine of its input. xs is consumed lazily, [1..natLength xs] is produced lazily, a

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

2006-10-19 Thread Brandon Moore
David House wrote: On 19/10/06, Brandon Moore <[EMAIL PROTECTED]> wrote: isIdentity xs = xs == takeLengthOf xs [1..] where takeLengthOf xs ys = zipWith const ys xs You probably mean zipWith (flip const) xs ys. Either way, as long as I didn't write "zipWith const xs ys". for finite lists, ta

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

2006-10-19 Thread Nils Anders Danielsson
On Thu, 19 Oct 2006, Tomasz Zielonka <[EMAIL PROTECTED]> wrote: > On Thu, Oct 19, 2006 at 01:37:16PM -0400, Cale Gibbard wrote: > >> In order to determine if [1..length xs] has an element at all, you >> have to evaluate length xs, which involves forcing the entire spine of >> xs, because integers

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

2006-10-19 Thread David House
On 19/10/06, Brandon Moore <[EMAIL PROTECTED]> wrote: isIdentity xs = xs == takeLengthOf xs [1..] where takeLengthOf xs ys = zipWith const ys xs You probably mean zipWith (flip const) xs ys. for finite lists, takeLengthOf xs ys == take (length xs) ys This ruins the laziness again: Hugs.Ba

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

2006-10-19 Thread Brandon Moore
Nicolas Frisby wrote: I may have missed this in the discussion so far, but it seems we could use a summary. In short: isIdentity does not check for exact equivalence, only a prefix equivalence. That's why it doesn't exhibit the same time/space behavior as a reformulation based on full equivalenc

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

2006-10-19 Thread Nicolas Frisby
I may have missed this in the discussion so far, but it seems we could use a summary. In short: isIdentity does not check for exact equivalence, only a prefix equivalence. That's why it doesn't exhibit the same time/space behavior as a reformulation based on full equivalence. More verbosely: isI

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

2006-10-19 Thread Tomasz Zielonka
On Thu, Oct 19, 2006 at 01:37:16PM -0400, Cale Gibbard wrote: > >Why is this so? I'd have thought that the equality function for lists > >only forces evaluation of as many elements from its arguments as to > >determine the answer. > > In order to determine if [1..length xs] has an element at all,

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

2006-10-19 Thread Robert Dockins
On Oct 19, 2006, at 12:51 PM, David House wrote: On 19/10/06, Mikael Johansson <[EMAIL PROTECTED]> wrote: isIdentity xs = all (\(i,j) -> i==j) (zip [1..] xs) isIdentity' xs = xs == [1..(length xs)] Then isIdentity 1:3:2:[4..10] finishes in an instant, whereas isIdentity' 1:3:2:[4..10]

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

2006-10-19 Thread Cale Gibbard
On 19/10/06, David House <[EMAIL PROTECTED]> wrote: On 19/10/06, Mikael Johansson <[EMAIL PROTECTED]> wrote: > isIdentity xs = all (\(i,j) -> i==j) (zip [1..] xs) > isIdentity' xs = xs == [1..(length xs)] > > Then > isIdentity 1:3:2:[4..10] > finishes in an instant, whereas > isIdentity' 1:3:

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

2006-10-19 Thread David House
On 19/10/06, Mikael Johansson <[EMAIL PROTECTED]> wrote: isIdentity xs = all (\(i,j) -> i==j) (zip [1..] xs) isIdentity' xs = xs == [1..(length xs)] Then isIdentity 1:3:2:[4..10] finishes in an instant, whereas isIdentity' 1:3:2:[4..10] takes noticable time before completing. Why is th

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

2006-10-19 Thread Henning Thielemann
On Thu, 19 Oct 2006, Mikael Johansson wrote: > On Thu, 19 Oct 2006, Mikael Johansson wrote: > > Comparing the code for permutationgropus at > > http://www.polyomino.f2s.com/david/haskell/codeindex.html > > with my own thoughts on the matter, I discover the one line to figure out > > whether a spe

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

2006-10-19 Thread Mikael Johansson
On Thu, 19 Oct 2006, Mikael Johansson wrote: Comparing the code for permutationgropus at http://www.polyomino.f2s.com/david/haskell/codeindex.html with my own thoughts on the matter, I discover the one line to figure out whether a specific list represents the identity: isIdentity (PL xs) = al

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

2006-10-19 Thread Bulat Ziganshin
Hello Andrea, Wednesday, October 18, 2006, 9:34:28 PM, you wrote: > solution? Or just some hints on the kind of problem I'm facing: is it > related to strictness/laziness, or it's just that I did not understand > a single bit of how garbage collection works in Haskell? i think, the second. unfor

Re: [Haskell-cafe] Error building Edison 1.2.0.1

2006-10-19 Thread Gregory Wright
On Oct 18, 2006, at 8:47 AM, Robert Dockins wrote: On Oct 17, 2006, at 1:46 PM, Gregory Wright wrote: On Oct 17, 2006, at 1:07 PM, Robert Dockins wrote: On Oct 17, 2006, at 12:55 PM, Gregory Wright wrote: Hi Rob, I've built Edison 1.2.0.1 using ghc-6.6. (I'm testing the macports,

[Haskell-cafe] List comparisons and permutation group code

2006-10-19 Thread Mikael Johansson
Comparing the code for permutationgropus at http://www.polyomino.f2s.com/david/haskell/codeindex.html with my own thoughts on the matter, I discover the one line to figure out whether a specific list represents the identity: isIdentity (PL xs) = all (\(i,j) -> i==j) (zip [1..] xs) Is there a

Re: [Haskell-cafe] Re: A better syntax for qualified operators?

2006-10-19 Thread Brian Smith
On Wed, Oct 18, 2006 at 04:42:00PM +0100, Simon Marlow wrote:> So you won't be able to colour patterns differently from expressions, that > doesn't seem any worse than the context vs. type issue.  Indeed, I'm not> even sure you can colour types vs. values properly, look at this:>>   data T = C [Int

[Haskell-cafe] Thanks !! (was: Newbie and working with IO Int and Int)

2006-10-19 Thread Víctor A. Rodríguez
I want to thanks you all for your helps regarding this issue. You've been very helpful and comprehensive. Salute !! -- Víctor A. Rodríguez (http://www.bit-man.com.ar) El bit Fantasma (Bit-Man) Perl Mongers Capital Federal (http://cafe.pm.org/) GNU/Linux User Group - FCEyN - UBA (http://glugcen.dc.

[Haskell-cafe] RE: [Haskell] Lexically scoped type variables

2006-10-19 Thread Simon Peyton-Jones
| just one more problem is that this issue is too complicated. i'm not | sure that i correctly understands details, but for me the situation | seems like this: in 6.4 it was no distinction between declarations and | usages of type variables - first use declared it, while in 6.6 we have | exactly de

Re: [Haskell-cafe] beginner's problem about lists

2006-10-19 Thread Eugene Crosser
Sorry, I realized that it does not cover the shorter [1..5] (shorter [2..] [3..]) case... Eugene Crosser wrote: > On Tue, 10 Oct 2006 [EMAIL PROTECTED] wrote: >> Hi all, >> I'm trying to implement a function that returns the shorter one of two given >> lists, >> something like >> shorter :: [a]

Re: [Haskell-cafe] beginner's problem about lists

2006-10-19 Thread Eugene Crosser
On Tue, 10 Oct 2006 [EMAIL PROTECTED] wrote: > Hi all, > I'm trying to implement a function that returns the shorter one of two given > lists, > something like > shorter :: [a] -> [a] -> [a] > such that shorter [1..10] [1..5] returns [1..5], > and it's okay for shorter [1..5] [2..6] to return eithe