Range consolidation: Difference between revisions
m
→{{header|JavaScript}}: (Tidying)
(→{{header|Javascript}}: Added a JS draft.) |
m (→{{header|JavaScript}}: (Tidying)) |
||
Line 281:
// consolidated :: [(Float, Float)] -> [(Float, Float)]
const consolidated = xs =>
const
[x, y] = xy;
return y >= b ? (
cons(xy, etc)
Line 292 ⟶ 294:
cons([x, b], etc)
) : cons(xy, abetc);
})() : [xy]
) : [
)
console.log(
Line 362 ⟶ 363:
(a, b) => f(b, a)
) : (x => y => f(y)(x));
// foldl :: (a -> b -> a) -> a -> [b] -> a
const foldl = (f, a, xs) => xs.reduce(f, a);
// fst :: (a, b) -> a
|