You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I want to generate string that matchs regex \\w, but generated string contains obviously too many Underscores. Does java.util.Random's unevenness cause this?
The following is sample code. (I'm Sorry, I use Kotlin, not Java)
funmain(args:Array<String>) {
val value =Generex("\\w{1000}").random()
val counter = mutableMapOf<Char, Int>()
for (v in value.toList()) {
val c = counter.get(v)
when (c) {
null-> counter.put(v, 1)
else-> counter.put(v, c +1)
}
}
counter.toList().sortedByDescending { it.second }.take(10).forEach {
println("char: ${it.first}, count: ${it.second}")
}
}
// sample result// char: _, count: 225// char: 3, count: 38// char: 8, count: 30// char: 4, count: 29// char: 9, count: 28// char: 5, count: 27// char: 1, count: 27// char: 7, count: 24// char: 2, count: 24// char: 0, count: 22
The text was updated successfully, but these errors were encountered:
Hi. I want to generate string that matchs regex
\\w
, but generated string contains obviously too many Underscores. Doesjava.util.Random
's unevenness cause this?The following is sample code. (I'm Sorry, I use Kotlin, not Java)
The text was updated successfully, but these errors were encountered: