Brace expansion: Difference between revisions

Content added Content deleted
(Added 11l)
Line 266: Line 266:
|}
|}
<hr style="clear:both; margin-bottom:1em;"/>
<hr style="clear:both; margin-bottom:1em;"/>

=={{header|11l}}==
{{trans|Python}}
<lang 11l>F getitem(=s, depth = 0)
V out = [‘’]
L s != ‘’
V c = String(s[0])
I depth & (c == ‘,’ | c == ‘}’)
R (out, s)
I c == ‘{’
V x = getgroup(s[1..], depth + 1)
I !x[0].empty
[String] nout
L(a) out
L(b) x[0]
nout.append(a‘’b)
out = nout
s = x[1]
L.continue
I c == "\\" & s.len > 1
(s, c) = (s[1..], c‘’s[1])
out = out.map(a -> a‘’@c)
s = s[1..]
R (out, s)

F getgroup(=s, depth)
[String] out
V comma = 0B
L s != ‘’
V gs = getitem(s, depth)
s = gs[1]
I s == ‘’
L.break
out [+]= gs[0]

I s[0] == ‘}’
I comma
R (out, s[1..])
R (out.map(a -> ‘{’a‘}’), s[1..])

I s[0] == ‘,’
(comma, s) = (1B, s[1..])
R ([‘’] * 0, ‘’)

L(s) ‘~/{Downloads,Pictures}/*.{jpg,gif,png}
It{{em,alic}iz,erat}e{d,}, please.
{,{,gotta have{ ,\, again\, }}more }cowbell!
{}} some }{,{\\{ edge, edge} \,}{ cases, {here} \\\\\}’.split("\n")
print(([s] [+] getitem(s)[0]).join("\n\t")"\n")</lang>
{{out}}
<pre>
~/{Downloads,Pictures}/*.{jpg,gif,png}
~/Downloads/*.jpg
~/Downloads/*.gif
~/Downloads/*.png
~/Pictures/*.jpg
~/Pictures/*.gif
~/Pictures/*.png
...
{}} some }{,{\\{ edge, edge} \,}{ cases, {here} \\\\\}
{}} some }{,{\\ edge \,}{ cases, {here} \\\\\}
{}} some }{,{\\ edge \,}{ cases, {here} \\\\\}
</pre>


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==