[Haskell-cafe] Mystery operator?

2009-11-30 Thread michael rice
From: http://www.haskell.org/haskellwiki/Blow_your_mind#Polynomials   -- splitting in two (alternating)   -- 1234567 - (1357, 246)   -- the lazy match with ~ is necessary for efficiency, especially enabling processing of infinite lists   foldr (\a ~(x,y) - (a:y,x)) ([],[]) This works but can't

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Jochem Berndsen
michael rice wrote: From: http://www.haskell.org/haskellwiki/Blow_your_mind#Polynomials -- splitting in two (alternating) -- 1234567 - (1357, 246) -- the lazy match with ~ is necessary for efficiency, especially enabling processing of infinite lists foldr (\a ~(x,y) - (a:y,x))

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Brandon S. Allbery KF8NH
On Nov 30, 2009, at 12:47 , michael rice wrote: From: http://www.haskell.org/haskellwiki/Blow_your_mind#Polynomials -- splitting in two (alternating) -- 1234567 - (1357, 246) -- the lazy match with ~ is necessary for efficiency, especially enabling processing of infinite lists foldr

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread michael rice
So, ALL patterns are strict, unless one precedes them with ~? Michael --- On Mon, 11/30/09, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: From: Brandon S. Allbery KF8NH allb...@ece.cmu.edu Subject: Re: [Haskell-cafe] Mystery operator? To: michael rice nowg...@yahoo.com Cc: Brandon S

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Brandon S. Allbery KF8NH
On Nov 30, 2009, at 13:26 , michael rice wrote: So, ALL patterns are strict, unless one precedes them with ~? case patterns are strict (this includes pattern matching in function arguments). let patterns are lazy. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell]

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Daniel Fischer
Am Montag 30 November 2009 19:26:13 schrieb michael rice: So, ALL patterns are strict, unless one precedes them with ~? Or they appear in a let-binding: Prelude let f xs = let (x:y:zs) = xs in True Prelude f [] True Michael ___ Haskell-Cafe

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Daniel Fischer
Am Montag 30 November 2009 19:32:01 schrieb Brandon S. Allbery KF8NH: On Nov 30, 2009, at 13:26 , michael rice wrote: So, ALL patterns are strict, unless one precedes them with ~? case patterns are strict (this includes pattern matching in function arguments). let patterns are lazy. And of

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread michael rice
that would dictate choosing one over the other. Thanks, Michael --- On Mon, 11/30/09, Daniel Fischer daniel.is.fisc...@web.de wrote: From: Daniel Fischer daniel.is.fisc...@web.de Subject: Re: [Haskell-cafe] Mystery operator? To: haskell-cafe@haskell.org Date: Monday, November 30, 2009, 1:35 PM

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread David Menendez
On Mon, Nov 30, 2009 at 2:01 PM, michael rice nowg...@yahoo.com wrote: Hi all, A lot of things posted here I wasn't aware of. My original example involved ~(x,y), so, returning to that context, how would these two simple cases vary: add2 :: (Int,Int) - Int add2 (x,y) = x+y add2 ::

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Ryan Ingram
Consider these two functions: z = ([], []) alt1 = foldr f z where f a (x,y) = (a:y, x) alt2 = foldr g z where g a ~(x,y) = (a:y, x) alt1 (1:2:3:undefined) = foldr f z (1:2:3:undefined) = f 1 (foldr f z (2:3:undefined)) -- Now f 1 needs to evaluate its second argument for the pattern

Re: [Haskell-cafe] Mystery operator?

2009-11-30 Thread Daniel Fischer
Am Montag 30 November 2009 20:01:04 schrieb michael rice: Hi all, A lot of things posted here I wasn't aware of. My original example involved ~(x,y), so, returning to that context, how would these two simple cases vary: add2 :: (Int,Int) - Int add2 (x,y) = x+y add2 :: (Int,Int) - Int