This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume we have ponyfilled versions of array methods | |
const map = (arr, cb) => [].map.call(arr, cb); | |
const reduce = (arr, cb) => [].reduce.call(arr, cb); | |
// What we wanna do without ponyfills | |
const res = [1,2,3] | |
.map(x => x * 10) | |
.reduce((cur, prev) => cur + prev); | |
// What we can do with ponyfills |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result = 0; | |
const sleep = (ms) => new Promise((resolve)=>{ | |
setTimeout(resolve, ms); | |
}); | |
const mult = async(val) => { | |
await sleep(200); | |
return val * val; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <future> | |
#include <vector> | |
#include <iterator> | |
#include <thread> | |
/// <summary> | |
/// Maps collection using function f1, then reduces resulting collection using f2 on defined number of threads | |
/// </summary> | |
/// <param name="p">Iterator pointing at the start of collection</param> | |
/// <param name="q">Iterator pointing at the end of collection</param> |