package moe.nea.firmament.util object StringUtil { fun String.words(): Sequence { return splitToSequence(" ") // TODO: better boundaries } fun parseIntWithComma(string: String): Int { return string.replace(",", "").toInt() } fun Iterable.unwords() = joinToString(" ") fun nextLexicographicStringOfSameLength(string: String): String { val next = StringBuilder(string) while (next.lastOrNull() == Character.MAX_VALUE) next.setLength(next.length - 1) if (next.isEmpty()) return "" // There is no upper bound. Fall back to the empty string val lastIdx = next.indices.last next[lastIdx] = (next[lastIdx] + 1) return next.toString() } }