wasm-demo/demo/ermis-f/python_m/cur/1126

38 lines
1.2 KiB
Plaintext

From: Scott.Kelley at Colorado.edu (KELLEY SCOTT T)
Date: Fri, 23 Apr 1999 16:08:52 -0600
Subject: Efficient List Subtraction
Message-ID: <3720EF73.CA7DDEFF@Colorado.edu>
X-UID: 1126
Does anyone out there have a simple way to compare two lists (some operator perhaps) and
return
a list of *differences*? By differences, I mean the following: If had two
lists like,
a = [1, 4, 5, 100]
b = [4, 5]
the difference between a and b (a-b) would be [1, 100]. I suppose you could
write a couple of for loops to go through each list and compare them, but I
thought there might be a simple way to do this.
I'm also interested in a simple way to returning a list of what is identical between the
two lists.
In the case of the above lists, a and b, they both contain [4, 5].
If anyone out there has a suggestion (or two) I would very much appreciate it.
Cheers! -Scott
-------------------------------------------------------------------
Scott Kelley Phone: 303-492-1474
Dept. MCD Biology Fax: 303-492-7744
Campus Box 347 E-mail: Scott.Kelley at Colorado.edu
University of Colorado
Boulder, CO 80309-0347