<@U0926QHA6>: Why do you say it's not possible to ...
# announcements
c
@apatrida: Why do you say it's not possible to add a filter function as a parameter? This works fine:
Copy code
val 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 = "" )