Roman numerals/Encode: Difference between revisions
→JS Functional
m (→{{header|TypeScript}}: Comment: Weights and symbols in tuples.) |
|||
Line 3,610:
"use strict";
//
// roman :: Int -> String
const roman = n =>
mapAccumL(residue
([k, v]) => second(
q => 0 < q ?
)(remQuot(residue)(v))
)(n)(
zip([
Line 3,631:
.join("");
// ---------------------- TEST -----------------------▼
▲ // ---------------------- TEST -----------------------
// main :: IO ()
const main = () => (
Line 3,640:
// ---------------- GENERIC FUNCTIONS ----------------
type: "Tuple",▼
// mapAccumL :: (acc -> x -> (acc, y)) -> acc ->
Line 3,661 ⟶ 3,651:
const tpl = f(a[0])(x);
return
a[1].concat(tpl[1])
},
);
//
const
n =>
Line 3,681 ⟶ 3,670:
// to a function over a tuple.
// f (a, b) -> (a, f(b))
xy =>
Line 3,701 ⟶ 3,680:
length: Math.min(xs.length, ys.length)
}, (_, i) => [xs[i], ys[i]]);
// MAIN --
|