List comprehensions: Difference between revisions
m
→ES6
(→JS ES6: Deleted redundant line, added code tags to preamble, bound 'pure' to x => [x]) |
m (→ES6) |
||
Line 1,011:
// concatMap :: (a -> [b]) -> [a] -> [b]
const concatMap = (f, xs) => [].concat.apply([], xs.map(f));
// pure :: a -> [a]▼
const pure = x => [x];▼
// enumFromTo :: Int -> Int -> [Int]
const enumFromTo = (m, n) =>
Line 1,017 ⟶ 1,020:
length: Math.floor(n - m) + 1
}, (_, i) => m + i);
▲ // pure :: a -> [a]
▲ const pure = x => [x];
|