这个点免怎么写?

How to write this point-free?

我可以用 ramda 写这个吗?

const getJobs = data => anotherF('/jobs', data)

可能是

const getJobs = anotherF('/jobs', nthArg(0))

谢谢

您可以使用 R.partial 将 /jobs' 应用于函数,并且 return 一个需要 data:

的新函数

const anotherF = (path, data) => console.log(path, data)

const getJobs = R.partial(anotherF, ['/jobs'])

getJobs('data')
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.js"></script>

如果anotherF已经是柯里化函数,那么你可以只写

const getJobs = anotherF('/jobs')

所以,如果不是curried,或者你不知道,可以这样写

const getJobs = curry(anotherF)('/jobs')

但我们有充分的理由怀疑为什么这样做是值得的。我是 Ramda 的创始人之一,也是 Ramda 的忠实粉丝,但我认为它是一个工具包,可以让我的代码更易于阅读和编写。任何其他用途似乎都是误用。