<div dir="ltr">Hello all,<div><br></div><div>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:<br><br>    unique :: Eq a => [a] -> [a]<br>    unique xs = [x | (x,y) <- zip xs [0..], x `notElem` (take y xs)]<br><br>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.<br><br>So the first generator should produce [(Eq,Int)] as input to the second generator? And the second generator should produce [Bool]?<br><br>My understanding must be wrong though; how do we end up with just the items where the second generator produced True?<br><br>Thanks,<font color="#888888"><br><div><br></div></font></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div>Ken Overton</div><div>(917) 863-3937</div><div><a href="mailto:ken.overton@gmail.com" target="_blank">ken.overton@gmail.com</a></div><div><br></div></div></div>