Created
July 2, 2018 12:39
-
-
Save note35/87c2d5b9e88a4dbc09954a2bd76ccc75 to your computer and use it in GitHub Desktop.
Revisions
-
startling revised this gist
Apr 3, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,6 @@ def __init__(self, predicate): def __contains__(self, obj): return obj is not self and self.predicate(obj) # no sets contain themselves, so this is always False. R = Set(lambda s: s not in s) print R in R -
startling created this gist
Apr 3, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ class Set(object): """Sets can contain anything, including themselves. This leads to paradoxical behavior: given R, the set of all sets that don't contain themselves, does R contain R? Here this becomes an infinite recursion. """ def __init__(self, predicate): self.predicate = predicate def __contains__(self, obj): return self.predicate(obj) # We hit the recursion limit with this: R = Set(lambda s: s not in s) print R in R This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ class Set(object): """If we add another stipulation -- no sets contain themselves -- we exorcise this particular paradox. """ def __init__(self, predicate): self.predicate = predicate def __contains__(self, obj): return obj is not self and self.predicate(obj) # we can do this just fine, though -- it's always False because no sets contain # themselves. R = Set(lambda s: s not in s) print R in R