I'm tempted to suggest that "transposer" would be a better name than "demuxer", because it seems like the basic result is to transpose a matrix of values. But I realize you're also converting a list of "xSV" text-string rows into a transposed matrix -- two operations in one function.
Some purists would point out that it's better to keep the two operations distinct. (Converting a list of xSV strings into a matrix is pretty simple and applies to lots of situations, and the same is true for transposing a matrix, so why not just use the two simple functions one after the other, rather than create a relatively complex function to do both things at once?) Their argument would be that the single-job functions are easier to create, maintain and use because they are simpler in all respects -- apart from the fact that these particular two functions have already been solved, probably numerous times in different ways, in existing modules and common programming idioms.
Still, that is certainly an educational use of "map". It may not be optimal in terms of run-time or memory usage (I don't know, I haven't tried to benchmark it against any alternative, but I'll bet a faster technique can be found), but it is worth studying.
In reply to Re: Demuxer
in thread Transposer
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||