史上最简单的柯里化curry
const curry=fn=>{
const g= (...args)=>args.length>=fn.length?fn(...args):(...rest)=>g(...args,...rest)
return g
}
测试之
const fn=(a,b,c,d)=>{
console.log(a,b,c,d)
}
const go=curry(fn)
go(1)(2)(3)(4)
const curry=fn=>{
const g= (...args)=>args.length>=fn.length?fn(...args):(...rest)=>g(...args,...rest)
return g
}
测试之
const fn=(a,b,c,d)=>{
console.log(a,b,c,d)
}
const go=curry(fn)
go(1)(2)(3)(4)
发表评论 (审核通过后显示评论):