Chris Angelico wrote:
> If you're removing multiple, it's usually best to filter. This is a
> great opportunity to learn about list comprehensions and the
> difference between O(n) and O(n²) :)
> ChrisA
It would be O(n) if done right. And could be much more efficient than a list
comprehension, be
Multiple times I wished that sets had an `intersects` method. Simply the
negation of the `set.isdisjoint` method. Sometimes I can write `not
a.isdisjoint(b)`, but:
1) Together with the "dis", that's a double negation. Saying "a.intersects(b)"
is the correct and much clearer way to express my in
Chris Angelico wrote:
> Here's the equivalent as a list comprehension, which I think looks
> better than either of the above:
> [x + 1 for x in [1,2,3] if x % 2 == 0]
That's not equivalent. You produce [3] instead of [2, 4]. So you rather proved
that the proposal does have merit, as it's apparent
On Thu, Dec 23, 2021 at 05:23:00PM -, Stefan Pochmann wrote:
> Multiple times I wished that sets had an `intersects` method. Simply
> the negation of the `set.isdisjoint` method.
There are so many ways to get this:
def intersects(a, b):
return not a.isdisjoint(b)
Not ever one-l