new python syntax: concatenation of functions

Radovan Garabik garabik at kassiopeia.juls.savba.sk
Thu Mar 11 07:06:21 EST 2004


Uwe Mayer <merkosh at hadiko.de> wrote:
> 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? ;)

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!



More information about the Python-list mailing list