Hello everybody,
I run into a problem and I don’t know if I’m doing something really wrong or if I don’t understand how the filters of list comprehensions work. I wrote the following code:
for x <- 0..2, y <- 0..2, do: {x,y}
which creates the list:
[{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {1, 2}, {2, 0}, {2, 1}, {2, 2}]
pretty good so far. But now I want to exclude the tuple {1,1} from it. So I wrote my code like this:
for x <- 0..2, y <- 0..2, (x != 1) && (y != 1), do: {x,y}
but the generated list now excludes every tuple that contains a single 1.
EDIT: the above line is wrong, it obviously doesn’t exclude every tuple with a 1 in it, but tuple {1,2} is missing.
EDIT2: I copy pasted the wrong line, that’s why my list was wrong, actually every 1 is excluded. So Edit1 is wrong.
[{0, 0}, {0, 2}, {2, 0}, {2, 2}]
Am I doing something horribly wrong?
Thanks in advance.
Greetings,
eXodiquas