[Haskell-beginners] List comprehensions with multiple generators
Francesco Ariis
fa-ml at ariis.it
Mon Apr 27 02:18:07 UTC 2020
On Sun, Apr 26, 2020 at 10:26:48AM -0400, Ken Overton wrote:
> I guess if I actually wanted the case all the pairs were evaluated and
> resulted in [Bool] where the first occurrence of an item were True, rather
> than multiple generators I would have two nested list comprehensions?
I am not sure I understand what you are trying to achieve, but there
is always the possibility of bringing the `y` and the "filter" before
the guard:
uniqueInternal :: Eq a => [a] -> [(a, Int, Bool)]
uniqueInternal xs = [(x,y, x `notElem` take y xs) | (x,y) <- zip xs [0..]]
More information about the Beginners
mailing list