Cantor set: Difference between revisions

m
(→‎JavaScript :: Dual representation: Updated primitives, tidied.)
Line 1,833:
// intervalRatios :: [(Rational, Rational)] -> String
const intervalRatios = xs => {
const go = tplab =>
Array.from(tplab).map(
compose(showRatio, rational)
)
Line 1,846:
const go = w => xs =>
snd(mapAccumL(
a => tplab => {
const [wx, wy] = Array.from(tplab).map(
r => ratioMult(w)(
rational(r)
Line 1,951:
 
// fst :: (a, b) -> a
const fst = tplab =>
// First member of a pair.
tplab[0];
 
 
Line 2,018:
acc => xs => [...xs].reduce(
(a, x) => {
const tplab = f(a[0])(x);
 
return [tplab[0], a[1].concat(tplab[1])];
},
[acc, []]
Line 2,146:
 
// snd :: (a, b) -> b
const snd = tplab =>
// Second member of a pair.
tplab[1];
 
 
9,655

edits