Re: [Haskell-beginners] another list comprehesion error

On 22.07.2011 08:46, Roelof Wobben wrote:
Now try this instead: roelof' n = [x | x<- [1..n]] What do you get for "roelof' 4" ? A error message that a instance of print is missing.
Then you have a typo somewhere...
Now you can try the last two with guards.
2) cannot be done without guards and list comprehession generator [ 2,4 ..10] does not work
Sure it can: [ 2*x-1 | x <- [1..5]] and even easier: [1,3..10] or, better still (but not only a list comprehension any more): take 5 [1, 3..]
3) cannot be done withut guards and list comprehession because of the a<=b
This, too, can be done: [ (b, a) | a <- [1..5], b <- [1..a]] Regards, Thomas

Oke, Thanks. I was wondering one thing and I think at this moment too difficult for me, But can you with a list comprehession read one list and alter another list. For example: You have a list of numbers Now you would calculate the average value and put the outcome in another list. Just wondering so you have to say it can or cannot be done. Roelof ----------------------------------------
Date: Fri, 22 Jul 2011 11:31:07 +0200 From: haskell@phirho.com To: beginners@haskell.org Subject: Re: [Haskell-beginners] another list comprehesion error
On 22.07.2011 08:46, Roelof Wobben wrote:
Now try this instead: roelof' n = [x | x<- [1..n]] What do you get for "roelof' 4" ? A error message that a instance of print is missing.
Then you have a typo somewhere...
Now you can try the last two with guards.
2) cannot be done without guards and list comprehession generator [ 2,4 ..10] does not work
Sure it can: [ 2*x-1 | x <- [1..5]] and even easier: [1,3..10] or, better still (but not only a list comprehension any more): take 5 [1, 3..]
3) cannot be done withut guards and list comprehession because of the a<=b
This, too, can be done: [ (b, a) | a <- [1..5], b <- [1..a]]
Regards, Thomas
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Hi, Roelof.
When you are working to unders
_____________________
David F. Place
Owner, Panpipes Ho!, LLC
http://panpipesho.com
On Jul 22, 2011, at 6:37 AM, Roelof Wobben

Whoops, sorry. I swiped the tiny send button on my iPhone. Hi, Roelof. When you are working to understand examples from "Programming in Haskell" perhaps you can give page numbers so we can follow along. Cheers, David ____________________ David Place Owner, Panpipes Ho! LLC http://panpipesho.com d@vidplace.com On Jul 22, 2011, at 10:27 AM, David Place wrote:
Hi, Roelof.
When you are working to unders
_____________________ David F. Place Owner, Panpipes Ho!, LLC http://panpipesho.com
On Jul 22, 2011, at 6:37 AM, Roelof Wobben
wrote: _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Oke', But they are not examples but exercises. Roelof ----------------------------------------
Subject: Re: [Haskell-beginners] another list comprehesion error From: d@vidplace.com Date: Fri, 22 Jul 2011 10:32:03 -0400 CC: rwobben@hotmail.com; beginners@haskell.org To: d@vidplace.com
Whoops, sorry. I swiped the tiny send button on my iPhone.
Hi, Roelof.
When you are working to understand examples from "Programming in Haskell" perhaps you can give page numbers so we can follow along.
Cheers, David
____________________ David Place Owner, Panpipes Ho! LLC http://panpipesho.com d@vidplace.com
On Jul 22, 2011, at 10:27 AM, David Place wrote:
Hi, Roelof.
When you are working to unders
_____________________ David F. Place Owner, Panpipes Ho!, LLC http://panpipesho.com
On Jul 22, 2011, at 6:37 AM, Roelof Wobben
wrote: _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (3)
-
David Place
-
Roelof Wobben
-
Thomas