Brace expansion: Difference between revisions

use the new introheader template
(add REXX)
(use the new introheader template)
Line 3:
Brace expansion is a type of parameter expansion [[wp:Bash_%28Unix_shell%29#Brace_expansion|made popular by Unix shells]], where it allows users to specify multiple similar string parameters without having to type them all out. E.g. the parameter <code>enable_{audio,video}</code> would be interpreted as if both <code>enable_audio</code> and <code>enable_video</code> had been specified.
 
{{introheader|The Task}}
<p style="font-size:115%; margin:1em 0 0.5em 0;">'''''The Task'''''</p>
 
Write a function that can perform brace expansion on any input string, according to the following specification.<br>
Demonstrate how it would be used, and that it passes the four test cases given below.
 
{{introheader|Specification}}
<p style="font-size:115%; margin:1em 0 0.5em 0;">'''''Specification'''''</p>
 
In the input string, balanced pairs of braces containing comma-separated substrings <small>(details below)</small> represent ''alternations'' that specify multiple alternatives which are to appear at that position in the output. In general, one can imagine the information conveyed by the input string as a tree of nested alternations interspersed with literal substrings, as shown in the middle part of the following diagram:
Line 224:
For every possible input string, your implementation should produce exactly the output which this specification mandates. Please comply with this even when it's inconvenient, to ensure that all implementations are comparable. However, none of the above should be interpreted as instructions (or even recommendations) for '''how''' to implement it. Try to come up with a solution that is idiomatic in your programming language. ''(See [[#Perl]] for a reference implementation.)''
 
{{introheader|Test Cases}}
<p style="font-size:115%; margin:1em 0 0.5em 0">'''''Test Cases'''''</p>
 
{| class="wikitable" style="white-space: nowrap;"
Anonymous user