Daniel van den Eijkel schrieb:
If xs is a list,
xs >>= f
is the same as (concat (map f xs)). Take a look at the monad instance
for lists. So, in
[1..] >>= \x -> ....
x is "every" element of the list. Example:
[1,2,3] >>= \x -> [x, x*2]
is
concat
[ (\x -> [x, x*2]) 1
, (\x -> [x, x*2]) 2
, (\x -> [x, x*2]) 3
]
is
concat [ [1,1], [2,4], [3,6] ]
typo: should be [1,2]
is
[1,1,2,4,3,6]
... and [1,2, ...
hope that helps. best regards,
daniel
michael rice schrieb:
getLine >>= \x -> -- x is a string at this
point
[1..] >>= \x -> -- x is WHAT at this point?
MIchael
--- On Sun, 8/8/10, Henning Thielemann <[email protected]>
wrote:
From: Henning Thielemann <[email protected]>
Subject: Re: [Haskell-cafe] What is <-
To: "michael rice" <[email protected]>
Cc: [email protected]
Date: Sunday, August 8, 2010, 9:38 AM
On Sun, 8 Aug 2010, michael rice wrote:
> So, Example 2 desugared becomes...
>
> [1..] >== \z -> ?
Yes, [1..] >>= \z -> ...
|
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
|