Skip to content

onceknown/ordered-cartesian-product

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ordered Cartesian Product

Function that takes an ordering sequence and a mapping of dimensions and outputs the ordered cartesian product of combinations.

let combos = OrderedCartesianProduct(
  ["x", "y"],
  {
    "x": [1, 2, 3],
    "y": [4, 5, 6]
  }
)
console.log(combos);
/*
[
  {"x": 1, "y": 4},
  {"x": 1, "y": 5},
  {"x": 1, "y": 6},
  {"x": 2, "y": 4},
  {"x": 2, "y": 5},
  {"x": 2, "y": 6},
  {"x": 3, "y": 4},
  {"x": 3, "y": 5},
  {"x": 3, "y": 6}
]
*/

About

Record-style wrapper around cartesian product algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published