当前位置:网站首页>浅聊组合函数
浅聊组合函数
2022-08-02 15:01:00 【InfoQ】
const multi10 = function(x) { return x * 10; }
const toStr = function(x) { return `${x}`; }
const compute = function(x){
return toStr(multi10(x))
}
compute(8)
fn3(fn2(fn1(fn0(x))))
const compose = function(f,g) {
return function(x) {
return f(g(x))
}
}
let compute = compose(toStr, multi10)
compute(8)
compose
function compose(...funs){
return (x) =>funs.reduce((acc, fun) => fun(acc), x)
}
React
边栏推荐
猜你喜欢
随机推荐
PAT甲级 1078 哈希
遍历堆 PAT甲级 1155 堆路径
【 Leetcode string, the string transform/hexadecimal conversion 】 HJ1. The length of the string last word HJ2. Calculation of a certain number of characters appear HJ30. String merging processing
Apache APISIX 2.15 版本发布,为插件增加更多灵活性
Qt | 事件系统 QEvent
Basic management of system storage -- mounts, partitions, user quotas
太帅了!我用炫酷大屏展示爬虫数据!
为什么我不再推荐枚举策略模式?
Drag and Drop in H5
浅析PM2实用入门指南
vite.config.ts 引入 `path` 模块注意点!
【Leetcode字符串--字符串变换/进制的转换】HJ1.字符串最后一个单词的长度 HJ2.计算某字符出现次数 HJ30.字符串合并处理
【无标题】
多线程------实际篇
Reading is the cheapest and noblest
PAT serie a 1137 final grades
codeforces k-Tree (dp still won't work)
PAT Grade A 1143 Lowest Common Ancestor
太香了!阿里Redis速成笔记,从头到尾全是精华!
Qt | 信号和槽的一些总结