高阶列表操作重命名背后的基本原理

发布于 2024-09-25 03:39:31 字数 167 浏览 0 评论 0原文

C# 中重命名高阶列表操作的基本原理是什么? (示例:map -> Selectfilter -> Wherefold > -> 聚合)

What was the rationale behind renaming of higher order list operations in C#? (Examples: map -> Select, filter -> Where, fold -> Aggregate)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

ヤ经典坏疍 2024-10-02 03:39:31

LINQ 试图让了解 SQL 的人大致熟悉,其中投影选择等。当然,您可以使用适合的名称编写自己的扩展方法。

LINQ tries to be roughly familiar to people knowing SQL, where projection is select, etc. You could write your own extension methods with names to suit, of course.

离线来电— 2024-10-02 03:39:31

关于元问题……

函数式编程社区和主流命令式编程社区长期以来一直在彼此近乎隔离的状态下发展。因此,词汇方面存在根本差异;例如,像“多态性”这样的常用术语对于每个组来说意味着完全不同的事物(参数多态性,对于 FP 者来说又名“泛型”或“模板”;与其他人的子类型多态性相对)。

询问名称背后的基本原理(如果有的话)通常会得到一个简单的答案 - 您根据“当地文化”命名东西。在C#中,LINQ是一种类似于SQL的查询语言,因此它看起来很像SQL。

但问这个问题大致类似于去西班牙询问每个人称他的房子为“mi casa”的理由是什么。 (“你的意思是为什么我这么称呼它?这就是它的名字!你的意思是你称它为不同的东西?”)

Regarding the meta-question...

The functional programming community and mainstream imperative programming community have evolved in near-isolation from one another for a long time. As a result, there are fundamental vocabulary differences; for example, a common term like "polymorphism" means completely different things to each group (parametric polymoprhism, a.k.a. "generics" or "templates" to the FP-ers; versus subtype polymorphism to the rest).

Asking for the rationale behind names (if there even is one) often results in one simple answer - you name stuff according to the "local culture". In C#, LINQ is a query language like SQL, so it looks a lot like SQL.

But asking this question is roughly analogous to going to Spain and asking what the rationale is for everyone calling his house "mi casa". ("What do you mean why do I call it that? That's what it's called! You mean you call it something different?")

尽揽少女心 2024-10-02 03:39:31

不是答案,但值得一提:

请参阅 http://blogs.msdn.com/b/jaredpar/archive/2008/12/02/mapping-linq-to-f.aspx 用于 LINQ 之间的“解码器环”转换(如C#/Enumerable)和 F# Seq 函数(大多遵循更传统的函数名称)。

Not an answer, but a worthy aside:

See http://blogs.msdn.com/b/jaredpar/archive/2008/12/02/mapping-linq-to-f.aspx for a 'decoder ring' translation between LINQ (as in C#/Enumerable) and F# Seq functions (which mostly follow the more traditional functional names).

无戏配角 2024-10-02 03:39:31

嗯,在我看来,“折叠”对于“聚合”来说是一个非常糟糕的名字。那些疯狂的数学家。 :) 大多数情况下,C# 名称更符合 SQL/LINQ。

Well, IMO, "fold" is a pretty terrible name for "Aggregate". Freaking math people. :) Mostly though the C# names are more in-line with SQL/LINQ.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文