Skip to content

Instantly share code, notes, and snippets.

@aledoroshenko
Last active November 2, 2016 15:41
Show Gist options
  • Save aledoroshenko/b209a090ba8d1874640443b945a1f309 to your computer and use it in GitHub Desktop.
Save aledoroshenko/b209a090ba8d1874640443b945a1f309 to your computer and use it in GitHub Desktop.
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>
import _ from 'lodash/fp';
import expect from 'expect';
const b = [['a', 'b'], ['c', 'd'], ['e', 'f']];
const fn = (memo, coll) => _.flatMap( _memo => _.map( _coll => _memo.concat([_coll]) ) (coll) ) (memo);
console.table(_.reduce(fn, [[]], b));
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"expect": "1.20.2",
"lodash": "4.16.4"
}
}
'use strict';
var _fp = require('lodash/fp');
var _fp2 = _interopRequireDefault(_fp);
var _expect = require('expect');
var _expect2 = _interopRequireDefault(_expect);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var b = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var fn = function fn(memo, coll) {
return _fp2.default.flatMap(function (_memo) {
return _fp2.default.map(function (_coll) {
return _memo.concat([_coll]);
})(coll);
})(memo);
};
console.table(_fp2.default.reduce(fn, [[]], b));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment