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)
本文标题:史上最简单的柯里化curry
本文链接:https://www.haomeiwen.com/subject/lpplgktx.html
网友评论