Multiplication tables: Difference between revisions

m
(→‎{{header|JavaScript}}: Added ES6 version)
Line 2,648:
const multTable = (m, n) => {
const xs = enumFromToInt(m, n);
return cons([
cons(['x', ...xs)],
...concatMap(
x => [cons(x, concatMap(
y => y < x ? [''] : [x, * y],...concatMap(
xs y => y < x ? [''] : [x * y],
))], xs
)]
],
xs
)
)];
};
 
Line 2,696 ⟶ 2,698:
// concatMap :: (a -> [b]) -> [a] -> [b]
const concatMap = (f, xs) => [].concat.apply([], xs.map(f));
 
// cons :: a -> [a] -> [a]
const cons = (x, xs) => [x, ...xs];
 
// enumFromToInt :: Int -> Int -> [Int]
9,659

edits