Hi Monks,
I need to generate combinations of values and populate it in a hash of hashes. Say Eg:
f1 = (1,2) f2 = (3,4,5) f3 = (6,7)
I get 12 unique combinations out of these(2*3*2). Like:
f1 f2 f3
1 3 6
1 3 7
1 4 6
1 4 7
.
.
2 3 6
.
.
2 5 7
All these combinations should be stored as values under each field key(f1 or f2 or f3). But the problem is in generation of combinations as THE NO. OF FIELDS IS VARIABLE!!
All fields and their values are stored in array. I need to construct a table of the above combinations. Plz help
for(1 to n of f1)
{
for(1 to n of f2)
{
for(1 to n of f3)
{
store f11 f21 f31 to f3last element
}
}
}
this can be used provided we know the actual field count.
But what can be done for occurance of random number of fields with their respective values??
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.