[Javascript] Coding interview problem: Scheduler functional way
Implement a job scheduler which takes in a function f and an integer n, and calls f after nmilliseconds
function curry (fn) {
const arity = fn.length;
return function $curry(...args) {
if (args.length < arity) {
return $curry.bind(null, ...args);
}
return fn.call(null, ...args);
}
}
const setScheduler = curry((ms, fn) => {
return setTimeout(() => fn(), ms)
});
const halfSecond = setScheduler();
console.log('before');
halfSecond(() => console.log('Timeup'));
setTimeout(() => console.log('after'), );
// |A A: before
// |-----B B: Timeup
// |------C C: after
[Javascript] Coding interview problem: Scheduler functional way的更多相关文章
- 转:Top 10 Algorithms for Coding Interview
The following are top 10 algorithms related concepts in coding interview. I will try to illustrate t ...
- whiteboard & coding interview practice
whiteboard & coding interview practice 白板 & 面试 & 编码练习 Algorithm https://www.freecodecamp ...
- Cracking the coding interview
写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...
- Cracking the coding interview 第一章问题及解答
Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...
- Cracking the Coding Interview(Trees and Graphs)
Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...
- Cracking the Coding Interview(Stacks and Queues)
Cracking the Coding Interview(Stacks and Queues) 1.Describe how you could use a single array to impl ...
- crack the coding interview
crack the coding interview answer c++ 1.1 #ifndef __Question_1_1_h__ #define __Question_1_1_h__ #i ...
- 《Cracking the Coding Interview》读书笔记
<Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...
- Cracking the coding interview目录及资料收集
前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...
随机推荐
- BZOJ.2527.[POI2011]MET-Meteors(整体二分)
题目链接 BZOJ 洛谷 每个国家的答案可以二分+求前缀和,于是可以想到整体二分. 在每次Solve()中要更新所有国家得到的值,不同位置的空间站对应不同国家比较麻烦. 注意到每次Solve()其国家 ...
- 写在OI退役后和高中毕业前的一些话
更新日志: 2017.02.13 开坑 2017.02.13 更新[零][壹] 2017.02.14 更新[贰] 2017.02.26 更新[叁][肆] 2017.03.04 锅多如狗,停更一周 20 ...
- [BZOJ2669] [cqoi2012]局部极小值
[BZOJ2669] [cqoi2012]局部极小值 Description 有一个n行m列的整数矩阵,其中1到nm之间的每个整数恰好出现一次.如果一个格子比所有相邻格子(相邻是指有公共边或公共顶点) ...
- 证明自己吧--------Writeup
原题:http://www.shiyanbar.com/ctf/28 下载一个压缩包,里面有个CrackMe1.exe,查看了下,没有壳. 直接拖到ida去反汇编 一进来就是在main里面,直接F5看 ...
- PHP获取目录和文件的方法
PHP获取当前目录和相对目录的方法<?php //获取当前文件所在目录,如果 A.php include B.php 则无论写在哪个文件里,都是表示 A.php 文件所在的目录 echo rea ...
- 模拟拖拽图片 碰撞检测 DOM 鼠标事件 闭包
<!doctype html><html lang="en"> <head> <meta charset="UTF-8" ...
- weblogic安装以及异常解决方法【转】
转自:http://shenjc2008.iteye.com/blog/1461253 下载地址: http://www.oracle.com/technetwork/middleware/weblo ...
- LM358资料及引脚图
LM358里面包括有两个高增益.独立的.内部频率补偿的双运放,适用于电压范围很宽的单电源,而且也适用于双电源工作方式,它的应用范围包括传感放大器.直流增益模块和其他所有可用单电源供电的使用运放的地方使 ...
- 利用Jenkins实现JavaWeb项目的自动化部署
修改代码,打包,上传,重启... 大把的时间花费在这些重复无味的工作上.笔者与当前主流的价值观保持一致:我们应该把时间花费在更有意义的事情上.我们可以尝试借助一些工具,让这些重复机械的工作交给计算机去 ...
- IIS 未能从程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral,
在Windows Server 2008中的IIS服务器中部署WCF服务程序时,通过浏览器访问报出如下错误: 未能从程序集“System.ServiceModel, Version=3.0.0.0, ...