Anonymous user
Brace expansion: Difference between revisions
→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
||
Line 1,674:
var sb = StringBuilder("")
var i1 = noEscape.indexOf('{')
var i2 =
outer@ while (i1 != -1) {
Line 1,682:
while (i2 < s.length && depth > 0) {
val c = noEscape[i2]
if (c == '{')▼
if (c == '{') depth++
else if (c == '}') depth--
if (c == ',' && depth == 1) sb[i2] = '\u0000'
else if (c ==
i2++
}
Line 1,695 ⟶ 1,693:
}
if (i1 == -1) {
if (suf.
else
} else
for (m in sb.substring(i1
expandR(pre + s.substring(0, i1), m, s.substring(i2 + 1) + suf)
}
}
|