Let's say I have a struct Product with an unknown and variable amount of attributes-values. The attributes-values come from a user at runtime. One product with a unique combination of attributes and values form a product_variant.
For intance, user may create 4 attributes:
- size (5 values)
- material (3 values)
- design (2 values)
- colour (9 values)
and thus there'll be 5 * 3 * 2 * 9 = 270 unique product variants.
Example:
product_variant with:
%{
size => m,
material => paper,
design => ds_abc,
colour => red,
}
How do I traverse all the attributes with their respective values and thus create 270 unique product variants? What'll be an algorithm?
The number of attributes may be any and isn't known at compile time. There're 4 here, but there can be any number and they, amount and names, aren't known up front - they get resolved at runtime.
Not with a library one-line function.