宇宙集 [英] A Universe Set
问题描述
是否曾建议添加Universe Set对象。比如U
= set(0),那么任何对象都是U的成员?也许这会变成
一些疯狂的Cantorian东西,因为U在U.但似乎它会有用并且与emptyset具有良好的对称性:set([ ]),
是:
对于任何对象a:
" a in set([])"返回False
" a in set(0)"返回True
Has the addition of a Universe Set object ever been suggested. Like U
= set(0), so that any object was a member of U? Maybe this gets into
some crazy Cantorian stuff since U is in U. But it seems like it would
be useful and would have a nice symmetry with emptyset:set([]), that
is:
for any object a:
"a in set([])" returns False
"a in set(0)" returns True
推荐答案
jo*********@gmail.com 写道:
是否曾建议添加Universe Set对象。比如U
= set(0),那么任何对象都是U的成员?
Has the addition of a Universe Set object ever been suggested. Like U
= set(0), so that any object was a member of U?
在[61]中:类UniverseSet(对象):
....:def __contains __(self,x):
....:返回True
....:
在[62]中:U = UniverseSet()
在[63]中:1在U
Out [63]:正确
在[64]中:2在U
Out [64]:正确
在[65]中:'''''''''''''''
out [ 65]:真实
在[66]中:U在U
Out [66]:正确
-
Robert Kern
我开始相信整个世界都是一个谜,一个无害的谜团
这太可怕了通过我们自己的疯狂尝试来解释它,好像它有一个潜在的真相。
- Umberto Eco
In [61]: class UniverseSet(object):
....: def __contains__(self, x):
....: return True
....:
In [62]: U = UniverseSet()
In [63]: 1 in U
Out[63]: True
In [64]: 2 in U
Out[64]: True
In [65]: ''something'' in U
Out[65]: True
In [66]: U in U
Out[66]: True
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
jo*********@gmail.com 写道:
jo*********@gmail.com wrote:
是否曾建议添加Universe Set对象。比如U
= set(0),那么任何对象都是U的成员?也许这会变成
一些疯狂的Cantorian东西,因为U在U.但似乎它会有用并且与emptyset具有良好的对称性:set([ ]),
是:
对于任何对象a:
" a in set([])"返回False
" a in set(0)"返回True
Has the addition of a Universe Set object ever been suggested. Like U
= set(0), so that any object was a member of U? Maybe this gets into
some crazy Cantorian stuff since U is in U. But it seems like it would
be useful and would have a nice symmetry with emptyset:set([]), that
is:
for any object a:
"a in set([])" returns False
"a in set(0)" returns True
>> class universe(object):
>>class universe(object):
... def __contains __(self,thing):
...返回True
...
... def __contains__(self, thing):
... return True
...
>> U = universe()
1 $ U
>>U = universe()
1 in U
True
True
>> U
中没有
>>None in U
True
True
>> U in
>>U in U
True
True
>>>
>>>
当然最后一个示例显示您的实施可能需要改变
,具体取决于您查看的方式拉塞尔的悖论......
问候
史蒂夫
-
史蒂夫霍顿+44 150 684 7255 +1 800 494 3119
Holden Web LLC / Ltd http ://www.holdenweb.com
Skype:holdenweb http ://holdenweb.blogspot.com
最近的Ramblings http://del.icio.us/steve.holden
Of course the last eexample shows that your implementation may need to
change depending on how you view Russell''s paradox ...
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
2006年10月3日星期二23:13:08 - 0500,Robert Kern< ro ********* @ gmail.comwrote:
On Tue, 03 Oct 2006 23:13:08 -0500, Robert Kern <ro*********@gmail.comwrote:
jo ********* @ gmail.com 写道:
>是否曾建议添加Universe Set对象。像U
= set(0),那么任何对象都是U的成员?
>Has the addition of a Universe Set object ever been suggested. Like U
= set(0), so that any object was a member of U?
在[61]中:类UniverseSet(对象):
....:def __contains __(self,x):
....:返回True
....:
In [61]: class UniverseSet(object):
....: def __contains__(self, x):
....: return True
....:
是的。但请注意,能够自己编写它是一回事,在标准库中拥有它并且知道任何人都是另一个。
我一直渴望对于一些类似的事情一段时间,我仍然没有
确定他们是好主意,还是因为在Uni学习功能而导致的脑损伤。例如:
- 通配符对象,与其他所有内容进行比较
- 无限xrange()s
- 黑洞函数''def f(* args):传递''
- 身份函数''def f(x):return x''
/ Jorgen
-
// Jorgen Grahn< grahn @ Ph''nglui mglw''nafh Cthulhu
\ X / snipabacken.dyndns.org R''lyeh wgah''nagl fhtagn!
Yes. But note that being able to write it yourself is one thing, having it
in the Standard Library and known to anyone is another.
I have been craving for some similar things for a while, and I''m still not
sure if they are good ideas, or brain damage caused by studying functional
programming at Uni. For example:
- the wildcard object, which compares equal to everything else
- infinite xrange()s
- the black hole function ''def f(*args): pass''
- the identity function ''def f(x): return x''
/Jorgen
--
// Jorgen Grahn <grahn@ Ph''nglui mglw''nafh Cthulhu
\X/ snipabacken.dyndns.org R''lyeh wgah''nagl fhtagn!
这篇关于宇宙集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!