Mian-Chowla sequence: Difference between revisions
→{{header|JavaScript}}: Updated JS for parallel to functional version in Python
m (→Functional Python: (uncurried nextMC)) |
(→{{header|JavaScript}}: Updated JS for parallel to functional version in Python) |
||
Line 650:
=={{header|JavaScript}}==
{{Trans|Python}} (
<lang javascript>(() => {
'use strict';
Line 677:
while (true) {
yield x;
[sumSet, x] =
}
}
//
const
// Set of sums -> Series up to n -> Next term in series
const valid = x => {
if (setSums.has(x
return
const x =
return [
),
]
};
// sumList :: [Int] -> Int -> [Int]
const sumList = (xs, n) =>
// Series so far -> additional term ->
[2 * n].concat(map(x => n + x, xs));
// GENERIC FUNCTIONS ----------------------------
// drop :: Int -> [a] -> [a]
Line 723 ⟶ 719:
) : (take(n, xs), xs);
// Returns Infinity over objects without finite length.
Line 774 ⟶ 768:
22526,23291,23564,23881,24596,24768,25631,26037,26255,27219
[Finished in 0.
(Executed in the Atom editor, using Run Script)</pre>
|