Talk:Brace expansion: Difference between revisions

now I understand :-)
(now I understand :-))
 
(19 intermediate revisions by 5 users not shown)
Line 76:
 
:::::::: {a,a,b} --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 22:48, 31 January 2014 (UTC)
 
::::::::: #Perl, #Perl_6, #Python all expand that to the three alternatives &nbsp;<code>a</code>&nbsp; <code>a</code>&nbsp; <code>b</code>&nbsp; (like the spec requires). --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 22:57, 31 January 2014 (UTC)
:::::::::: My point was that the spec does not explicitly require this. I think that the spec should not neglect this issue. Or let me know if you think I should try to come up with further variations on this theme? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 23:02, 31 January 2014 (UTC)
 
::::::::::: Well the second bullet point of the spec includes an example which showcases duplicate alternatives. But I additionally added the phrase "''(which need not be unique)''" now to that paragraph, to make it more explicit. --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 23:12, 31 January 2014 (UTC)
 
::::::::::: I tried the perl implementation against this spec. If I use the pattern ab{c,d\,e{f,g\h},i\,j{k,l\,m}n,o\,p}qr I see no result line which contains both an 'f' and a 'k'. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 01:10, 1 February 2014 (UTC)
 
:::::::::::: It would be incorrect if it did so, since f and k come from different alternatives, separated by the comma before the i. Alternatives separated by comma are expanded internally and exclusively from each other—one never takes a cross product over a comma, only over braces. --[[User:TimToady|TimToady]] ([[User talk:TimToady|talk]]) 02:01, 1 February 2014 (UTC)
 
:::::::::::: The tree of nested alternation groups for that pattern is:
<pre style="margin-left:20em">
⎧c ⎫
⎪ ⎧f ⎫ ⎪
ab⎪d\,e⎩g\h⎭ ⎪qr
⎪ ⎧k ⎫ ⎪
⎪i\,j⎩l\,m⎭n⎪
⎩o\,p ⎭
</pre>
:::::::::::: Thus after recursive flattening ''(which effectively means collecting all the possibilities that you can get by going from left to right through that diagram)'', you get:
<tt style="margin-left:20em; color:#f00; display:block; background:#F9F9F9">
ab<span style="color:#191">c</span>qr<br>
ab<span style="color:#191">d\,e<span style="color:#00f">f</span></span>qr<br>
ab<span style="color:#191">d\,e<span style="color:#00f">g\h</span></span>qr<br>
ab<span style="color:#191">i\,j<span style="color:#00f">k</span>n</span>qr<br>
ab<span style="color:#191">i\,j<span style="color:#00f">l\,m</span>n</span>qr<br>
ab<span style="color:#191">o\,p</span>qr<br>
</tt>
:::::::::::: Which is exactly what the Perl solution prints. --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 02:07, 1 February 2014 (UTC)
::::::::::: Another datapoint: if you ignore the missing backslashes, bash output is identical to perl's and python's: abcqr abd,efqr abd,eghqr abi,jknqr abi,jl,mnqr abo,pqr. --[[User:TimToady|TimToady]] ([[User talk:TimToady|talk]]) 02:13, 1 February 2014 (UTC)
 
:::::::::::: Point taken. Thanks for the clarification. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 03:12, 1 February 2014 (UTC)
 
== Pls clarify edge case example ==
 
{}} some }{,{\\{ edge, edge} \,}{ cases, {here} \\\\\}
 
shouln't
 
{}} some }{ cases, {here} \\\\\}
 
be a solution? ..[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:27, 22 November 2015 (UTC)
 
: With all those backslashes and the braces without commas, all you're going to see from this algorithm is backslash pairs turning into single backslashes. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 15:40, 23 November 2015 (UTC)
:: Isn't this '{,{\\{ edge, edge} \,}' a choice between nothing and '{\\{ edge, edge} \,'--[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 22:38, 23 November 2015 (UTC)
:::My current program for this case shows:
<pre>
store 3 1 {}} some }{ cases, {here} \\\\\}
store 3 2 {}} some }\\{ edge \,{ cases, {here} \\\\\}
store 3 3 {}} some } edge \,{ cases, {here} \\\\\}
</pre>
:::is thie wrong? Why?? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 21:32, 24 November 2015 (UTC)
 
:::: That comma between ''some'' and ''edge'' is preceded by a brace which still hasn't found its dance partner when the music stops at the end. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 22:10, 24 November 2015 (UTC)
<pre>
:::::{}} some }{,{\\{ edge, edge} \,}{ cases, {here}...
:::::{}} some }{,{\** edge, edge} **}{ cases, {here}... I did this
:::::{}} some }{,{**{ edge, edge} **}{ cases, {here}... and should have done that
::::: | and that's the lonely brace</pre>
:::::Thanks --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 12:46, 25 November 2015 (UTC)
::::{
 
Sorry, I am still uncertain.
The results show:
<pre>
{}} some }{,{\\ edge \,}{ cases, {here} \\\\\}
</pre>
Why is the rightmost pair of braces not expanded into its 2 elements?
<pre>
111111
2222222222222
i.e. ' cases'
' {here} \\\\\'
</pre>
My result would be
<pre>
{}} some }{,{\\ edge \,} cases
{}} some }{,{\\ edge \,} {here} \\\\\
{}} some }{,{\\ edge \,} cases
{}} some }{,{\\ edge \,} {here} \\\\\
</pre>
..[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 14:52, 25 July 2016 (UTC)
 
: The right-most brace is escaped by a backslash. (<code>\\\\\}</code> = <code>\\ \\ \}</code>) --[[User:Smls|Smls]] ([[User talk:Smls|talk]]) 18:01, 25 July 2016 (UTC)
 
:: Thanks. removed my wrong understanding --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 06:49, 26 July 2016 (UTC)
2,294

edits