[Haskell-cafe] A function that makes list of Bool lists from list of Int lists

Maur Toter mauro19838 at gmail.com
Sat Apr 3 10:29:34 EDT 2010


Hey,

thanks for the help!

Yes it is part of a homework that I can't find out (I am fine with other
parts).
This is not the homework itself, just the part of it and I needed help with
it, thanks for that!
I would like to understand the solution and not only have it so I would like
to ask you:
What does the ($) at zipWith?

Thanks again!


On Sat, Apr 3, 2010 at 6:18 PM, Alexandru Scvortov <scvalex at gmail.com>wrote:

> Too many points.
>
> listbool :: [[a]] -> [[Bool]]
> listbool = zipWith ($) (map (map . const) (cycle [True, False]))
>
> Cheers,
> Alex
>
> On Saturday 03 April 2010 15:13:48 Edward Z. Yang wrote:
> > Excerpts from Maur Toter's message of Sat Apr 03 09:54:26 -0400 2010:
> > > I am new with Haskell so I think this will be a pretty dumb question.
> > > I would like to make a function that makes this:
> > >
> > > listbool :: [[Int]] -> [[Bool]]
> > >
> > > in this way:
> > > listbool [[1,2],[3,4]] == [[True, True],[False, False]]
> > > listbool [[1],[5,5],[5,4],[2]] == [[True],[False, False],[True, True],
> > > [False]]
> > >
> > > So always True from the elements of the first list, False from the
> > > elements of the second one, etc...
> >
> > Sure you can do this.  In fact, the type can be more general:
> >
> > listbool :: [[a]] -> [[Bool]]
> > listbool xs = zipWith ($) (map (\x -> map (const x)) (cycle [True,
> False]))
> > xs
> >
> > Cheers,
> > Edward
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100403/1bf6cd32/attachment-0001.html


More information about the Haskell-Cafe mailing list