cedric
11/17/2015, 1:27 PMval defaultFilter : (Char) -> Boolean = { it ->
it in '0'..'9' || it in 'a'..'z' || it in 'A'..'Z'
}
private fun generateRandomString(length:Int, filter: (Char) -> Boolean = defaultFilter) : String =
sequence { Random().nextInt(128) }
.map(Int::toChar)
.filter {
filter(it)
}
.take(length)
.joinToString( separator = "" )