什么是“免积分"?风格(在函数式编程中)? [英] What is "point free" style (in Functional Programming)?

查看:110
本文介绍了什么是“免积分"?风格(在函数式编程中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

首先,有一个这个问题,和<一个href ="https://stackoverflow.com/questions/907306/confusion-about-currying-and-point-free-style-in-haskell">这一个.

然后,我发现此处他们提到另一个可能值得讨论的主题是作者对点自由风格的厌恶."

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?

要了解我的水平-我一直在教我自己Scheme,并且编写了一个简单的Scheme解释器...我了解隐式"欺骗是什么,但我不知道任何Haskell或ML./p>

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.

推荐答案

只需查看 Wikipedia文章获取定义:

默认编程(无点编程)是一种编程范例,其中函数定义不包含有关其自变量的信息,而是使用组合器和函数组合而不是变量.

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示例:

Haskell example:

常规(您明确指定了参数):

Conventional (you specify the arguments explicitly):

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

无点(sum没有任何显式参数-只是+从0开始的折叠):

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

 sum = foldr (+) 0

或更简单:您只需编写g = f即可代替g(x) = f(x).

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

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

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

这篇关于什么是“免积分"?风格(在函数式编程中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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