Created
October 6, 2023 12:15
-
-
Save RobertTalbert/4e6170518270d8ad789aa430dcb81df7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use basic logic commands to "fake" set operations. | |
# Here's union: | |
U = [1,2,3,4,5,6,7,8,9,10] | |
A = [1,2,3,4,5,6] | |
B = [2,4,6] | |
# A union B | |
[x for x in U if ((x in A) or (x in B))] | |
# A intersect B | |
[x for x in U if ((x in A) and (x in B))] | |
# Fill in below for complement, difference, Cartesian product |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment