untitled notebook

node v8.15.0
version: 1.0.0
const R = require('ramda'); const list = [ 'abc', 'def' ];
const split = x => x.split(''); const nestedLists = R.map(split, list);
But now we have an Array<Array<string>> which is no good. Let's flatten that back out...
const backToList = R.flatten(nestedLists);
Turns out this pattern of `map` then `flatten` (often called join) can be written with one operation called `chain`.
R.chain(split, list)

no comments

    sign in to comment