made with esnextbin
Created
February 9, 2017 14:12
-
-
Save briancavalier/f6ea75048430d945735c7b923eac6a10 to your computer and use it in GitHub Desktop.
esnextbin sketch
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
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
const increasingInteger = (startAt) => () => [startAt, increasingInteger(startAt + 1)] | |
// Start at 0 | |
let next = increasingInteger(0); | |
let x; | |
[x, next] = next(); | |
console.log(x); // 0 | |
[x, next] = next(); | |
console.log(x); // 1 | |
[x, next] = next(); | |
console.log(x); // 2 | |
[x, next] = next(); | |
console.log(x); // 2 |
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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"babel-runtime": "6.22.0" | |
} | |
} |
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
"use strict"; | |
var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray"); | |
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var increasingInteger = function increasingInteger(startAt) { | |
return function () { | |
return [startAt, increasingInteger(startAt + 1)]; | |
}; | |
}; | |
// Start at 0 | |
var next = increasingInteger(0); | |
var x = void 0; | |
var _next = next(); | |
var _next2 = (0, _slicedToArray3.default)(_next, 2); | |
x = _next2[0]; | |
next = _next2[1]; | |
console.log(x); // 0 | |
var _next3 = next(); | |
var _next4 = (0, _slicedToArray3.default)(_next3, 2); | |
x = _next4[0]; | |
next = _next4[1]; | |
console.log(x); // 1 | |
var _next5 = next(); | |
var _next6 = (0, _slicedToArray3.default)(_next5, 2); | |
x = _next6[0]; | |
next = _next6[1]; | |
console.log(x); // 2 | |
var _next7 = next(); | |
var _next8 = (0, _slicedToArray3.default)(_next7, 2); | |
x = _next8[0]; | |
next = _next8[1]; | |
console.log(x); // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment