Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Unsubscribe (Christopher Ledbetter) ---------------------------------------------------------------------- Message: 1 Date: Mon, 27 Apr 2020 08:08:45 -0400 From: Christopher Ledbetter <cledbett...@yahoo.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Unsubscribe Message-ID: <0f16ec3f-f6d8-4ca9-9149-8cdd19c0d...@yahoo.com> Content-Type: text/plain; charset="utf-8" Unsubscribe Sent from my iPad > On Apr 26, 2020, at 8:51 AM, Ken Overton <ken.over...@gmail.com> wrote: > > > Hello all, > > I recently came across this function which made me realize I don't understand > list comprehensions well. I hope someone can help me understand them better > by understanding this example better. The function takes a list of Eq and > returns the list of unique elements from it: > > unique :: Eq a => [a] -> [a] > unique xs = [x | (x,y) <- zip xs [0..], x `notElem` (take y xs)] > > It's using a list comprehension with multiple 'generators' (hope I have the > term correctly). My understanding of multiple generators in a list > comprehension is that they refine the results of the previous generator. > > So the first generator should produce [(Eq,Int)] as input to the second > generator? And the second generator should produce [Bool]? > > My understanding must be wrong though; how do we end up with just the items > where the second generator produced True? > > Thanks, > > > -- > Ken Overton > (917) 863-3937 > ken.over...@gmail.com > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200427/30f29f33/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 142, Issue 6 *****************************************