dave08
01/01/2018, 2:00 PM"0101-1002-0909-0210-1115-1511".split("-")
.flatMap { it.chunked(2).map { it.toInt() } }
.map { if (it > 9) (it + 55).toChar() else (it + 48).toChar() }
.chunked(2)
I need: 11:A2:99:2A:BF:FB
, how could I do that idiomatically, also, is there a simpler algo for this? It's converting to hex..elizarov
01/01/2018, 2:37 PM"<tel:0101-1002-0909|0101-1002-0909>-0210-1115-1511".split("-")
.map { it.chunked(2)
.map { it.toInt().toString(16).toUpperCase() }
.joinToString(separator = "")
}.joinToString(separator = ":")
dave08
01/01/2018, 2:39 PM"<tel:0101-1002-0909|0101-1002-0909>-0210-1115-1511".split("-")
.joinToString(separator = ":") { it.chunked(2)
.joinToString(separator = "") { it.toInt().toString(16).toUpperCase() }
}
But your is maybe clearer.. is there a difference in performance? (I'm using this in a Vert.x api...)karelpeeters
01/02/2018, 7:26 AM"%02x".format(it)
.dave08
01/02/2018, 7:35 AMtoInt(16)
, or is there?), but your hint might help, thanks!karelpeeters
01/02/2018, 7:38 AMtoInt(16)
, bith without leading zeroes. Good luck!