ilya.gorbunov
06/11/2017, 3:43 AMbuildSequence {
val uniques = mutableSetOf<Int>()
list.forEach { if (!uniques.add(it)) yield(it) }
}.distinct()
ilya.gorbunov
06/11/2017, 3:46 AMmutableSetOf<Int>().let { uniques -> list.filterNotTo(mutableSetOf(), uniques::add) }
jw
06/11/2017, 3:48 AMjw
06/11/2017, 3:49 AMilya.gorbunov
06/11/2017, 3:50 AMjw
06/11/2017, 3:50 AMjw
06/11/2017, 3:51 AMjw
06/11/2017, 3:53 AMdistinct(): List<T>
potentially sets a precedent for a duplicates(): List<T>
ilya.gorbunov
06/11/2017, 3:56 AMjw
06/11/2017, 4:00 AMoleksandr.samsonov
06/16/2017, 11:04 PMjw
06/17/2017, 12:13 AMCloseable
going to move into the stdlib as a facade interface?jw
06/17/2017, 12:14 AM.use
on the JVM because it's only available on java.io.Closeableorangy
orangy
mg6maciej
06/17/2017, 8:02 AMDisposable
in rx.jw
06/17/2017, 1:39 PMjw
06/17/2017, 1:39 PMjw
06/17/2017, 1:39 PMorangy
mg6maciej
06/19/2017, 1:14 PMbyteArrayOf().joinToString("") { "%02x".format(it) }
.marcinmoskala
06/19/2017, 1:16 PMfun byteArrayToHexString(b: ByteArray) = b.joinToString(
separator = "",
transform = { byte -> Integer.toString((byte.toInt() and 0xFF) + 0x100, 16).substring(1) }
)
marcinmoskala
06/19/2017, 1:17 PMkirillrakhman
06/19/2017, 1:21 PMBigInteger
ilya.gorbunov
06/19/2017, 1:31 PMByteArray
to a hex string. It would be quite obvious to name this extension ByteArray.toHexString()
. However I'm not sure where to provide the inverse function.kirillrakhman
06/19/2017, 1:35 PMkirillrakhman
06/19/2017, 1:35 PMmarcinmoskala
06/19/2017, 1:37 PMmarcinmoskala
06/19/2017, 1:38 PMfun ByteArray.toHexString() = joinToString("") { byte -> Integer.toString((byte.toInt() and 0xFF) + 0x100, 16).substring(1) }
marcinmoskala
06/19/2017, 1:39 PMfun ByteArray.toHexString() = joinToString("") { byte -> "%02x".format(byte) }
But I would need to unit-test it to be sure if this one is ok