Long multiplication: Difference between revisions
Content added Content deleted
m (→Functional (ES 5): Removed a couple of unused parameter names from a .reduce function) |
|||
Line 2,398: | Line 2,398: | ||
// Javascript lacks an unbounded integer type |
// Javascript lacks an unbounded integer type |
||
// so this multiplication function |
// so this multiplication function takes and returns |
||
// |
// long integer strings rather than any kind of native integer |
||
Line 2,407: | Line 2,407: | ||
digitProducts(digits(num1), digits(num2)) |
digitProducts(digits(num1), digits(num2)) |
||
); |
); |
||
⚫ | |||
⚫ | |||
// digitProducts :: [Int] -> [Int] -> [Int] |
// digitProducts :: [Int] -> [Int] -> [Int] |
||
Line 2,436: | Line 2,436: | ||
function largeIntegerString(lstColumnValues) { |
function largeIntegerString(lstColumnValues) { |
||
var dctProduct = lstColumnValues |
var dctProduct = lstColumnValues |
||
.reduceRight(function (a, x |
.reduceRight(function (a, x) { |
||
var intSum = x + a.carried, |
var intSum = x + a.carried, |
||
intDigit = intSum % 10; |
intDigit = intSum % 10; |