Re: A small doubt

2001-10-22 Thread Artur Zawlocki
Marcin 'Qrczak' Kowalczyk wrote: > > What a pattern matches is independent from which of the variables > it binds are used. > > The pattern [a,b,c], or equivalently a::b::c::[], matches lists of > length 3. > (...) ... unless it matches lazily, as in let [a,b,c] = [1,2,3,4] in let [a

Re: A small doubt

2001-10-20 Thread Saswat Anand
Hi, I think a lazy pattern is "really lazy" if reference to a part of the pattern does not cause matching of rest of the pattern. For example, \ ~((:) a ((:) b [])) -> [a] should not try to match ((:) b[]) part of the pattern, since 'a' is only referenced. It seems the above pattern should

Re: A small doubt

2001-10-20 Thread Richard
Patrik Jansson writes: >No, I did not! The program is tested in hugs and ghci and does what it >"should". You are right; I was wrong. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: A small doubt

2001-10-20 Thread Patrik Jansson
On Sat, 20 Oct 2001, Richard wrote: > Patrik Jansson writes: > >This also works: (the (mis)match with the empty list is delayed > > until the end of time) > > > >> test5= let a: b: ~(c: ~[]) = "Hello" > >>in [a,b,c] > ^^^ > typo! You meant [a,b]. No, I d

Re: A small doubt

2001-10-20 Thread Richard
I just wrote: >Patrik Jansson writes: > >>> test5= let a: b: ~(c: ~[]) = "Hello" >>>in [a,b,c] > ^^^ >typo! You meant [a,b]. Never mind! Now I see the ~ in front of the []. Must look more closely before posting. ___ Haskell-C

Re: A small doubt

2001-10-20 Thread Richard
Patrik Jansson writes: >This also works: (the (mis)match with the empty list is delayed > until the end of time) > >> test5= let a: b: ~(c: ~[]) = "Hello" >>in [a,b,c] ^^^ typo! You meant [a,b]. >But this fails (if the full list is requested ...) > >> t

Re: A small doubt

2001-10-20 Thread Patrik Jansson
On Sat, 20 Oct 2001, Adrian Hey wrote: ... : Interesting. I always thought pattern matching was lazy, but it I don't think Haskell has changed here (recently). > main = print test3 This does not work: > test1= let [a,b,c] = "Hello" >in [a,b] Same here: > test2= let a: b: c: [] = "Hel

Re: A small doubt

2001-10-20 Thread Adrian Hey
On Saturday 20 October 2001 3:58 am, Saswat Anand wrote: > Hi, > I am wondering why this function should not work with input [x,y] > (list with two elements) too, since third element is not referenced. Why > is it so eager to pattern match. > > fun = \list -> let [a,b,c] = list >

Re: A small doubt

2001-10-19 Thread Marcin 'Qrczak' Kowalczyk
Sat, 20 Oct 2001 10:58:02 +0800 (GMT-8), Saswat Anand <[EMAIL PROTECTED]> pisze: > I am wondering why this function should not work with input [x,y] > (list with two elements) too, since third element is not referenced. What a pattern matches is independent from which of the variables it binds

A small doubt

2001-10-19 Thread Saswat Anand
Hi, I am wondering why this function should not work with input [x,y] (list with two elements) too, since third element is not referenced. Why is it so eager to pattern match. fun = \list -> let [a,b,c] = list in [a,b] Thanks, Saswat