标签:const awesome 多个 scheme 偏函数 区别 https func javascrip
偏函数应用(Partial Application)是指固定一个函数的某些参数,然后产生另一个更小元的函数。而所谓的元是指函数参数的个数,比如含有一个参数的函数被称为一元函数。
偏函数应用(Partial Application)与函数柯里化很容易混淆,它们之间的区别是:
偏函数实现
function partial(fn,...res){
return function(...args){
return fn.apply(this,[...res,...args])
}
}
function buildUrl(scheme, domain, path) {
return `${scheme}://${domain}/${path}`
}
const myGithubPath = partial(buildUrl, "https", "github.com")
console.log(myGithubPath("semlinker/semlinker"))
console.log(myGithubPath("semlinker/awesome-typescript"))
标签:const awesome 多个 scheme 偏函数 区别 https func javascrip
原文地址:https://www.cnblogs.com/zhenjianyu/p/13947786.html