Two sum: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
Hout (talk | contribs)
m →‎ES6: Minor simplification
Line 244:
// summingPairIndices :: -> Int -> [Int] -> [(Int, Int)]
let summingPairIndices = (n, xs) =>
concatMap((x, ix) => concatMap((y, iy) => {
return iy > ix ? [] : ( // Ignoring mirror image tuples
x + y === n ? [
[iy, ix]
] : []
), xs), xs);
}, xs), xs);
 
return summingPairIndices(21, [0, 2, 11, 19, 90]);