
22 Jul
2011
22 Jul
'11
9:31 a.m.
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