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)
out = out.product(x[0]).map{|a,b| a+b}▼
s, c = s[1..-1],
▲ end
end
end
return out, s
Line 1,931 ⟶ 1,928:
break if s.empty?
out += g
when '}' then return (comma ? out : out.map{|a| "{#{a}}"}), s[1..-1]
end
end
end
|