Talk:Brace expansion: Difference between revisions

Content added Content deleted
Line 20: Line 20:
== Duplicate supression ==
== Duplicate supression ==


The task currently has an ambiguity - specifically an explicit reference to an implementation (perl 6) which implements a requirement which is not explicitly stated in the task description.
The task currently has an ambiguity - specifically an explicit reference to an implementation (perl 6) which implements a requirement which is not explicitly stated in the task description. [Update: not a problem]


More specifically, the perl 6 implementation suppresses duplicate results despite no description of this mechanism in the current task description. Consider {a,a,b} as an example which would generate duplicates. This issue shows up in the test case '{,{,gotta have{ ,\, again\, }}more }cowbell!' where nested empty prefixes appear. This case should have eight expansions. You can easily see this by placing a letter to the left of each non-escaped comma.
More specifically, the perl 6 implementation suppresses duplicate results despite no description of this mechanism in the current task description. Consider {a,a,b} as an example which would generate duplicates. This issue shows up in the test case '{,{,gotta have{ ,\, again\, }}more }cowbell!' where nested empty prefixes appear. This case should have eight expansions. You can easily see this by placing a letter to the left of each non-escaped comma. [Update: not a problem]


This means either the task description is buggy or the reference implementation is buggy. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 18:31, 31 January 2014 (UTC)
This means either the task description is buggy or the reference implementation is buggy. [Update: not a problem] --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 18:31, 31 January 2014 (UTC)
:Well, I believe the task actually refers to the Perl (5) implementation, not the Perl 6 one. But leaving that aside, there's no duplicate suppression taking place here. Note what happens when I run these (through the Perl 6 version):
:Well, I believe the task actually refers to the Perl (5) implementation, not the Perl 6 one. But leaving that aside, there's no duplicate suppression taking place here. Note what happens when I run these (through the Perl 6 version):
<pre>{X,{Y,gotta have{ ,\, again\, }}more }cowbell!
<pre>{X,{Y,gotta have{ ,\, again\, }}more }cowbell!
Line 42: Line 42:


:The reference solution (Perl, not Perl 6) does agree with the spec: There should be no suppression of duplicates. As for the test case you mention, it has '''four''' expansions and not eight, because nested brace groups only expand the "branch" they belong to. For example, the pattern <code>aa{,{,11}cc}22</code> has three expansions (<code>aa22</code>&nbsp; <code>aacc22</code>&nbsp; <code>aa11cc22</code>), not four. --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 18:58, 31 January 2014 (UTC)
:The reference solution (Perl, not Perl 6) does agree with the spec: There should be no suppression of duplicates. As for the test case you mention, it has '''four''' expansions and not eight, because nested brace groups only expand the "branch" they belong to. For example, the pattern <code>aa{,{,11}cc}22</code> has three expansions (<code>aa22</code>&nbsp; <code>aacc22</code>&nbsp; <code>aa11cc22</code>), not four. --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 18:58, 31 January 2014 (UTC)

:: That's a good point, that brace expansion should be only relevant in the surrounding context where it appears. So that's my bug and hopefully I can find it now. Thank you. --~~