什么是功能编程中的点自由风格? [英] What is point free style in Functional Programming?

查看:155
本文介绍了什么是功能编程中的点自由风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到的短语是无点风格的概念...



首先,有问题,以及

然后,我发现了 =http://lambda-the-ultimate.org/node/3331 =nofollow noreferrer>这里他们提到另一个值得讨论的话题是作者不喜欢点自由的风格。



什么是无点风格?有人可以给出简明的解释吗?它与自动curry有关吗?



为了了解我的级别 - 我一直在教自己Scheme,并写了一个简单的Scheme解释器...我明白什么隐含currying是,但我不知道任何Haskell或ML。

解决方案

维基百科文章中找到您的定义:


Tacit编程(无点编程)是一种编程范例,其中函数定义不包括关于其参数的信息,使用组合器和函数组合[...]代替变量。


Haskell示例:



  sum(x:xs)= x +(sum xs)
sum [] = 0

无点( sum - 它只是一个折线 + 从0开始):

  sum = foldr(+)0 



或更简单:代替 g )= f(x),你可以写 g = f



所以是的:它与currying(或类似函数组合的操作)密切相关。


A phrase that I've noticed recently is the concept of "point free" style...

First, there was this question, and also this one.

Then, I discovered here they mention "Another topic that may be worth discussing is the authors' dislike of point free style."

What is "point free" style? Can someone give a concise explanation? Does it have something to do with "automatic" currying?

To get an idea of my level - I've been teaching myself Scheme, and have written a simple Scheme interpreter... I understand what "implicit" currying is, but I don't know any Haskell or ML.

解决方案

Just look at the Wikipedia article to get your definition:

Tacit programming (point-free programming) is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition [...] instead of variables.

Haskell example:

Conventional (you specify the arguments explicitly):

sum (x:xs) = x + (sum xs)
sum [] = 0

Point-free (sum doesn't have any explicit arguments - it's just a fold with + starting with 0):

 sum = foldr (+) 0

Or even simpler: Instead of g(x) = f(x), you could just write g = f.

So yes: It's closely related to currying (or operations like function composition).

这篇关于什么是功能编程中的点自由风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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