重新审视匿名功能 [英] Anonymus functions revisited

查看:62
本文介绍了重新审视匿名功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于George Sakkis提出了一种新的列表理解方式

http://groups-beta.google.com/group/...ff1b81fa70c8a7


让类似于元组的对象(x,y,z = 0)充当其他

元组的函数我想知道为什么这不是一个好的起点

重新思考匿名函数?

在Georges命题中,行动是


(x,y,z = 0) - > (x,y,z)


即映射其他元组的元组。这相当于


lambda x,y,z = 0:(x,y,z)


但是关于元组作为行动的箭头的装置 - >将

概括为这个想法:


这样的映射:


((x,y),z) - > x + y-z

((x,y = 0),z) - >没有


也应该是有效的行动。


观众在想什么?


关心Kay

Since George Sakkis proposed a new way of doing list comprehensions

http://groups-beta.google.com/group/...ff1b81fa70c8a7

letting tuples-like objects (x,y,z=0) acting as functions on other
tuples I wonder why this would not be a good starting point of
rethinking anonymus functions?

In Georges proposition the action is

(x,y,z=0) -> (x,y,z)

i.e. mapping tuples on other tuples. This is equivalent to

lambda x,y,z=0:(x,y,z)

But regarding tuples as actions by means of an arrow "->" would
generalize this idea:

Mappings like that:

((x,y),z) -> x+y-z

((x,y=0),z) -> None

should be valid actions too.

What is the audience thinking about that?

Regards Kay

推荐答案

Kay Schluehr写道:
Kay Schluehr wrote:
由于George Sakkis提出了一种新的做事方式理解

http://groups-beta.google.com/group/...ff1b81fa70c8a7

让类似元组的对象(x,y,z = 0)起作用作为其他元组的功能,我想知道为什么这不是重新思考匿名函数的良好起点?

在Georges的命题中,行动是
(x,y,z = 0) - > (x,y,z)

即在其他元组上映射元组。这相当于

lambda x,y,z = 0:(x,y,z)

但是关于元组作为动作的方法是通过箭头 - > ;"会概括这个想法:

这样的映射:

((x,y),z) - > x + y-z
((x,y = 0),z) - >没有

也应该是有效的行动。

观众在想什么?
Since George Sakkis proposed a new way of doing list comprehensions

http://groups-beta.google.com/group/...ff1b81fa70c8a7

letting tuples-like objects (x,y,z=0) acting as functions on other
tuples I wonder why this would not be a good starting point of
rethinking anonymus functions?

In Georges proposition the action is

(x,y,z=0) -> (x,y,z)

i.e. mapping tuples on other tuples. This is equivalent to

lambda x,y,z=0:(x,y,z)

But regarding tuples as actions by means of an arrow "->" would
generalize this idea:

Mappings like that:

((x,y),z) -> x+y-z

((x,y=0),z) -> None

should be valid actions too.

What is the audience thinking about that?




恕我直言,它这只是伪装的lambda,而且我不确定它比lambda更具可读性。你将不得不提供更多的论据(抱歉为双关语
! - )以获得我的附加力。 (注意:我可以毫无问题地使用这种语法,

只是我们已经有了这个语法)。

-

bruno desthuilliers

python -c" print''@''。join([''。''。join([w [:: - 1] for p in p.split( ''。'')])

p in''o **** @ xiludom.gro''。split(''''')])"



IMHO, it''s just lambda in disguise, and I''m not sure it''s more readable
than lambda. You''ll have to provide more arguments (sorry for the pun
!-) to gain my adhesion. (NB : I could use this syntax without problem,
it''s just that we already have a syntax for this).
--
bruno desthuilliers
python -c "print ''@''.join([''.''.join([w[::-1] for w in p.split(''.'')]) for
p in ''o****@xiludom.gro''.split(''@'')])"


2005年3月21日22:37:42 -0800,Kay Schluehr < ka ********** @ gmx.net>

写道:
On 21 Mar 2005 22:37:42 -0800, "Kay Schluehr" <ka**********@gmx.net>
wrote:
这样的映射:

((x,y = 0),z) - >没有

也应该是有效的行动。

观众在想什么?
Mappings like that:

((x,y),z) -> x+y-z

((x,y=0),z) -> None

should be valid actions too.

What is the audience thinking about that?




我认为有太多的暗示,从长远来看,如果我们继续添加特殊的快捷方式,它将导致非常难以读取代码的b $ b。



I think that there''s too much implied, and that in the long run it,
if we keep addding in special shortcuts, it will lead to very dificult
to read code.


>让类似元组的对象(x,y,z = 0)充当其他
> letting tuples-like objects (x,y,z=0) acting as functions on other
元组的函数我想知道为什么这不是重新考虑匿名函数的良好起点?

在乔治命题中,行动是

(x,y,z = 0) - > (x,y,z)

即在其他元组上映射元组。这相当于

lambda x,y,z = 0:(x,y,z)
tuples I wonder why this would not be a good starting point of
rethinking anonymus functions?

In Georges proposition the action is

(x,y,z=0) -> (x,y,z)

i.e. mapping tuples on other tuples. This is equivalent to

lambda x,y,z=0:(x,y,z)




正如你自己说的那样,那只是伪装的lambda。所以我猜这里有关于lambda的排除或排除的相同

参数。我个人

喜欢lambda,但_can_生活没有它。


-

问候,

Diez B. Roggisch



As you say for yourself, that''s just lambda in disguise. So I guess the same
arguments about the in- or exclusion of lambda apply here. I personally
like lambda, but _can_ live without it.

--
Regards,

Diez B. Roggisch


这篇关于重新审视匿名功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆