Cartesian product of two or more lists: Difference between revisions
Cartesian product of two or more lists (view source)
Revision as of 18:16, 18 September 2019
, 4 years ago→Functional JS: n-Ary version - a simpler and more maintainable foldr (using reduceRight)
(→Functional JS: Updated n-ary version.) |
(→Functional JS: n-Ary version - a simpler and more maintainable foldr (using reduceRight)) |
||
Line 1,170:
bind(as)(
x => bind(xs)(
a => [
[a].concat(x)
)
)
)([
// TEST -------------------------------------------
Line 1,204 ⟶ 1,208:
// foldr :: (a -> b -> b) -> b -> [a] -> b
const foldr = f => a => xs =>
▲ i = xs.length;
▲ return v;
▲ };
// intercalate :: String -> [a] -> String
|