
16 Sep
2018
16 Sep
'18
8:09 p.m.
Hello Olumide, On Mon, Sep 17, 2018 at 12:15:58AM +0100, Sola Aina wrote:
flatten( fmap (\a -> ( flatten( fmap ( \b -> return [a,b] ) coin ) ) coin )
Is this how to proceed and how am I to simplify this expression?
I get a slightly different final expression: flatten (fmap (\a -> flatten (fmap (\b -> return [a,b]) coin)) coin) -- notice the lack of `(` before the second `flatten` This could be rewritten as: flatMap (\a -> flatMap (\b -> return [a,b]) coin) coin -- flatMap :: (a1 -> Prob a2) -> Prob a1 -> Prob a2 -- flatMap f x = flatten (fmap f x) which is a bit easier on the eyes. This expression cannot be simplified any further if we don't bring to the table the definition of `coin`!