cedric
06/17/2016, 2:18 PMdalexander
06/17/2016, 2:22 PMcedric
06/17/2016, 2:23 PMdalexander
06/17/2016, 2:25 PMcedric
06/17/2016, 2:26 PMcedric
06/17/2016, 2:27 PMdalexander
06/17/2016, 2:28 PMdalexander
06/17/2016, 2:29 PMvoddan
06/17/2016, 2:48 PMraniejade
06/18/2016, 11:28 AMirus
06/18/2016, 11:29 AMvoddan
06/18/2016, 11:38 AMedvin
06/18/2016, 1:20 PMjkbbwr
06/20/2016, 3:30 PMinfix fun Int.pow(other: Int): Int {
return IntMath.pow(this, other)
}
fun Random.fromRange(start: Int, end: Int): Int {
return start + this.nextInt((end - start) + 1)
}
fun generateUid(): String {
return Random().fromRange(10 pow 15, 10 pow 16).toString()
}
Gosh don't extensions make things nicerhimrin
06/20/2016, 3:34 PMjkbbwr
06/20/2016, 3:37 PMsealed class Result<out T> {
class Failure(val message: String): Result<Nothing>()
class Success<out T>(val value: T): Result<T>()
object Ok : Result<Nothing>()
}
It could be modified to take throwables I guess but I quite like thisdean
06/20/2016, 3:46 PMilya.gorbunov
06/20/2016, 4:00 PMInt
range?orangy
hastebrot
06/20/2016, 7:52 PMDouble
.
fun main(args: Array<String>) {
println(Random().fromRange(10e15..10e16).toString())
}
fun Random.fromRange(range: ClosedRange<Double>): Double {
return lerp(range.start, range.endInclusive, nextDouble())
}
fun lerp(start: Double, end: Double, factor: Double) = start + ((end - start) * factor)
jkbbwr
06/20/2016, 7:52 PMhastebrot
07/06/2016, 3:51 PMsargunv
07/06/2016, 3:51 PMhastebrot
07/06/2016, 3:52 PMsargunv
07/06/2016, 3:52 PMsargunv
07/06/2016, 3:52 PMhastebrot
07/06/2016, 3:57 PMhimrin
07/06/2016, 3:58 PMhastebrot
07/06/2016, 4:00 PMhimrin
07/06/2016, 5:49 PM