Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
esnextbin sketch
<!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>
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
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"babel-runtime": "6.22.0"
}
}
"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
You can’t perform that action at this time.