这个功能有名称吗? [英] Is there a name for this function

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

问题描述

我正在寻找以下功能的名称:

I am looking for a name for the following function:

(f,a)=> ()=> f(a)

基本上是一个函数,它返回一个函数,当被调用时调用 f 使用 a

Basically a function that returns a function which when called calls f with a.

此功能是否有通用名称?也许它可以用一些 Ramda 魔术来描述?

Is there a common name for this function? maybe it can be described with some Ramda magic?

编辑澄清:

我正在寻找的是类似于Ramda的部分,

What I'm looking for is similar to Ramda's partial,

partial(f, [a])

除了部分更像是:

(f, a) => (b) => f(a, b)

b 的情况下,部分是不需要的。

推荐答案

这是< a href =https://en.wikipedia.org/wiki/Thunk =noreferrer> thunk 。

基本上,它是一个具体的您可以传递并按需评估的计算。人们可能想要延迟对表达式的评估有各种各样的原因(它可能很昂贵,它可能具有时间敏感的副作用等)。

Essentially, it's a reified computation that you can pass around and evaluate on demand. There are all sorts of reasons one might want to delay evaluation of an expression (it may be expensive, it may have time-sensitive side effects, etc.).

执行 const enThunk = f => a => ()=> f(a); 允许你传递 f(a),而不会在以后的某个时间点进行实际评估。

Doing const enThunk = f => a => () => f(a); lets you pass around f(a) without actually evaluating it until a later point in time.

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

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