新的python语法:函数的连接 [英] new python syntax: concatenation of functions
问题描述
我知道python社区不太愿意扩展
python语法。不过我想提出一个建议并听取你的专业建议
和利弊。
我想建议像数学这样的连接运算符:?°
这样:
a(b(c(d)))< => a?°b?°c(d)
现在,为什么你认为这样的扩展会完全没用? ;)
Ciao
Uwe
Hi,
I know the python community is not very receptive towards extending the
python syntax. Nevertheless I''d like to make a suggestion and hear your pro
and cons.
I want so suggest a concatenation operator like in mathematics: ?°
such that:
a(b(c(d))) <=> a?°b?°c(d)
Now, why do you think such an extension would be completely useless? ;)
Ciao
Uwe
推荐答案
Uwe Mayer< me *****@hadiko.de>写道:
Uwe Mayer <me*****@hadiko.de> wrote:
我知道python社区不太愿意扩展
python语法。不过我想提出一个建议并听取你的意见和建议。
我想建议像数学这样的连接运算符:?°
这样:< br(>(b(c(d)))< => a?°b?°c(d)
现在,为什么你认为这样的扩展是完全没用的? ;)
Hi,
I know the python community is not very receptive towards extending the
python syntax. Nevertheless I''d like to make a suggestion and hear your pro
and cons.
I want so suggest a concatenation operator like in mathematics: ?°
such that:
a(b(c(d))) <=> a?°b?°c(d)
Now, why do you think such an extension would be completely useless? ;)
因为在数学上人们都不同意订单:
a?°b(x)== a(b(x) )或
a?°b(x)== b(a(x))?
此外,我们的ASCII用完了
此外,它会更有意义地引入可定义的运算符,
?* la C ++
def(x)?°(y) :
返回lambda par:x(y(par))
打印(a?°b)(x)
或者,不离开ascii:
def(x)组成(y):
返回lambda par:x(y(par))
打印(合成b)(x)
-
----------- ------------------------------------------------ <无线电通信/>
| Radovan Garab?* k http://melkor.dnp.fmph.uniba .sk / ~glarabik / |
| __..-- ^^^ --..__ garabik @ kassiopeia.juls.savba.sk |
------------------- ----------------------------------------
防病毒警报:文件.signature被签名病毒感染。
嗨!我是一个签名病毒!将我复制到您的签名文件中以帮助我传播!
because neither in mathematics people agree on the order:
a?°b(x) == a(b(x)) or
a?°b(x) == b(a(x)) ?
besides, we are running out of ASCII
and besides, it would make more sence to introduce definable operators,
?* la C++
def (x)?°(y):
return lambda par: x(y(par))
print (a?°b)(x)
or, without leaving ascii:
def (x)composition(y):
return lambda par: x(y(par))
print (a composition b)(x)
--
-----------------------------------------------------------
| Radovan Garab?*k http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__ garabik @ kassiopeia.juls.savba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I''m a signature virus! Copy me into your signature file to help me spread!
Radovan Garabik写道:
Radovan Garabik wrote:
或者,不用离开ascii:
def(x)组成(y):
返回lambda par:x(y(par))
print(组合b)(x)
or, without leaving ascii:
def (x)composition(y):
return lambda par: x(y(par))
print (a composition b)(x)
>
或不离开Python
class构成:
def __init__(自我,外在,内在):
self.outer =外部
self.inner =内部
def __call__(自我,* args):
返回自我。外(self.inner(* args))
def __str __(自我):
返回''%s°%s''%(自我。外面,自我。)
Daniel
or without leaving Python
class Composition:
def __init__ (self, outer, inner):
self.outer = outer
self.inner = inner
def __call__ (self, *args):
return self.outer (self.inner (*args))
def __str__ (self):
return ''%s ° %s'' % (self.outer, self.inner)
Daniel
Radovan Garabik写道:
Radovan Garabik wrote:
因为在数学上人们都不同意这个顺序:
a?°b(x)== a(b(x))或
a?°b(x)== b( a(x))?
because neither in mathematics people agree on the order:
a?°b(x) == a(b(x)) or
a?°b(x) == b(a(x)) ?
这是个笑话还是什么?
数学ematics人员同意订单:
如果a:B-> A和b:X-> B,则a?°b:X-> A和
(a?°b)(x)= a(b(x))
Is this a joke or what?
In mathematics people DO agree on the order:
if a:B->A and b:X->B, then a?°b:X->A and
(a?°b)(x)=a(b(x))
这篇关于新的python语法:函数的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!