Overview
Creates every combination of two lists. It mechanically expands multiple axes of
variation, such as "2 sizes ร 3 colors = 6 combinations." A typical use is directly
before batch production with batch_render.
Usage tips
- The go-to batch-production chain is
variant_range(strength) +seed_range(seed) โcartesian_productโbatch_render. It produces "5 strength levels ร 4 seeds = 20 images" in one pass. - The number of entries grows multiplicatively (
a.len() ร b.len()). To add a third axis, pass the output through another Cartesian Product, but watch for a combinatorial explosion. - If you only need corresponding pairs, use
list_zipto avoid increasing the number of entries.
Related nodes
list_zipโ corresponding pairs instead of every combinationvariant_range/seed_rangeโ generate candidates for each axisbatch_renderโ batch-produce the expanded resultslist_mapโ post-process the combination table
Read this first
ListZipcombines items at the same index, whileCartesianProductcreates every combination.- 2 entries ร 3 entries produces 6 entries.
Start with this example
Provide these two lists:
a = ["small", "large"]
b = ["red", "blue", "green"]
The resulting entries value is:
[
{ "index": 0, "a_index": 0, "b_index": 0, "a": "small", "b": "red" },
{ "index": 1, "a_index": 0, "b_index": 1, "a": "small", "b": "blue" },
{ "index": 2, "a_index": 0, "b_index": 2, "a": "small", "b": "green" },
{ "index": 3, "a_index": 1, "b_index": 0, "a": "large", "b": "red" },
{ "index": 4, "a_index": 1, "b_index": 1, "a": "large", "b": "blue" },
{ "index": 5, "a_index": 1, "b_index": 2, "a": "large", "b": "green" }
]
count = 6
How downstream nodes see it
When you feed these entries to ListMap or ListFilter, you can use the following
fields directly in expressions:
indexa_indexb_indexab
For example:
a_index == 0
a + b
Working with Variant nodes
If a and b contain lists of VariantRecord values, a downstream BatchRender
automatically collects and uses the snapshots inside a and b. This makes the node
useful before multi-axis batch production, such as "strength candidates ร seed
candidates."
When to use it
- To create every combination of seed candidates and candidates for another parameter
- To represent a two-axis candidate space as explicit data
- To build a batch candidate table before generating variant candidates
Notes
- The result contains
a.len() * b.len()entries, so the number of candidates can grow very quickly. - A
Paletteis treated asList<Color>.