当前位置:网站首页>typeScript - Partially apply a function
typeScript - Partially apply a function
2022-08-04 23:58:00 【MXM_777】
function IsgoodNumber(a:number,v:number){
return v % a ===0
}
function filterArray(a:number[],f:(a:number,b:number)=>boolean){
return a.filter(f)
}
//Example
function ccc(f:(a:number,b:number)=>boolean,a:number){
return (b:number)=>{
return f(a,b)//a is a free variable
}
}
const goodnum =3
const a = [1,2,3,4,56,7,9]
// console.log(a.filter((v)=> v%2 ===0))
console.log(
filterArray(a,(v)=>IsgoodNumber(goodnum,v))
)
// console.log(
// filterArray(a,ccc(IsgoodNumber,goodnum))
// )
边栏推荐
猜你喜欢
3. Actual combat---crawl the result page corresponding to Baidu's specified entry (a simple page collector)
uniapp sharing function - share to friends group chat circle of friends effect (sorting)
The master teaches you the 3D real-time character production process, the game modeling process sharing
Xiaohei's leetcode journey: 95. Longest substring with at least K repeating characters
Modelers experience sharing: model study method
The market value of 360 has evaporated by 390 billion in four years. Can government and enterprise security save lives?
Handwritten Distributed Configuration Center (1)
情人节---快来学习一下程序员的专属浪漫吧
小黑leetcode冲浪:94. 二叉树的中序遍历
手写分布式配置中心(1)
随机推荐
What is next-generation modeling (with learning materials)
Chinese and Japanese color style
uniapp horizontal tab (horizontal scrolling navigation bar) effect demo (organization)
美团二面:Redis与MySQL双写一致性如何保证?
【无标题】线程三连鞭之“线程池”
mysql基础
入门3D游戏建模师知识必备
The applicable scenarios and common product types of the KT148A electronic voice chip ic solution
【论文笔记】—低照度图像增强—Unsupervised—EnlightenGAN—2019-TIP
性能测试如何准备测试数据
MYS-6ULX-IOT 开发板测评——使用 Yocto 添加软件包
MongoDB permission verification is turned on and mongoose database configuration
365天深度学习训练营-学习线路
【LeetCode】图解 904. 水果成篮
VMware NSX 4.0 -- 网络安全虚拟化平台
Nuclei (2) Advanced - In-depth understanding of workflows, Matchers and Extractors
中日颜色风格
Modelers experience sharing: model study method
三、实战---爬取百度指定词条所对应的结果页面(一个简单的页面采集器)
隐私计算综述