filtering random values (sieves?)
kevin parks
kp87 at lycos.com
Thu Feb 14 01:54:46 EST 2002
Uhmm... yeah. stupid me. As amazing as it seems, it never occured to
me to just generate the values i wanted in the first place.
But what i was hoping to do was generate two somewhat large lists
algorhytmically and use one list to filter the other, which would be
sort of like getting the interesection, like so:
def intersect(*args):
intersection = []
for x in args[0]:
for foo in args[1:]:
if x not in foo: break
else:
intersection.append(x)
return intersection
Not sure that is the best way, but the idea of just choosing from the
items in the first place is, uhmm <embarrasing mode on> obvious
</embarrasing mode off>
It's hard to find a rock big enough to crawl under. Boy sometimes the
answer really is right under your nose aint it?
best,
kevin
More information about the Python-list
mailing list