Brace expansion: Difference between revisions

Content added Content deleted
(Added Elixir)
(→‎{{header|Ruby}}: easy to understand.)
Line 1,911:
c = s[0]
break if depth>0 and (c == ',' or c == '}')
if c == '{' and x = getgroup(s[1..-1], depth+1)
xout = getgroupout.product(sx[1..-10]).map{|a,b| deptha+1)b}
ifs = x[1]
endelse
out = out.product(x[0]).map{|a,b| a+b}
s, c = s[1..-1], =c x+ s[1] if c == '\\' and s.size > 1
out, s = out.product(x[0]).map{|a,b| a+bc}, s[1..-1]
next
end
end
s, c = s[1..-1], c + s[1] if c == '\\' and s.size > 1
out, s = out.map{|a| a+c}, s[1..-1]
end
return out, s
Line 1,931 ⟶ 1,928:
break if s.empty?
out += g
ifcase s[0] == '}'
when '}' then return (comma ? out : out.map{|a| "{#{a}}"}), s[1..-1] if comma
return out.map{|a|when '{,' +then acomma, +s '}'}= true, s[1..-1]
end
comma, s = true, s[1..-1] if s[0] == ','
end
nil
end