Steven D'Aprano wrote:
> Can you sketch an O(n) algorithm for removing multiple items from an
> array, which *doesn't* involving building a temporary new list?
Here's what I meant. Have read/write indexes, delete the gap after maxcount
occurrences:
def remove(lst, value, maxcount):
read = w
Steven D'Aprano wrote:
> Or simpler still:
Yes, I didn't try to make it "simpler", but intentionally kept the
transformations as-is.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
h
Stefan Pochmann writes:
> Steven D'Aprano wrote:
> > Or simpler still:
>
> Yes, I didn't try to make it "simpler", but intentionally kept the
> transformations as-is.
But you didn't, really. As-is would use genexps to "inline" the map
and filter calls:
list(x for x in (y + 1 for y in