Saiedmomen
01/11/2019, 7:38 PMPremraj Motling
10/24/2020, 6:29 AMfun loadPage(offset: Int, limit: Int): List<Int> {
println("Called for offset $offset and limit $limit")
if (offset == 300) {
return listOf(offset + 10) // return 310 - last element
}
return (offset..offset + limit).take(limit)
}
fun paginatedCall() {
val limit = 100
var hasMore = true
val total = generateSequence(0) { if (hasMore) it + limit else null }
.map { loadPage(it, limit) }
.fold(0) { c, list ->
hasMore = list.size >= limit
println("Consumed list of size ${list.size}")
c + list.size
}
println("Total - $total")
}
paginatedCall()
Was wondering if there's any better way to implement paginatedCall
(assume loadPage
fetches records from DB)Chetan Tuteja
10/24/2020, 6:43 AM".2f".format()
sahil Lone
10/25/2020, 11:54 AMsahil Lone
10/25/2020, 11:54 AMtateisu
10/25/2020, 1:58 PMloke
10/25/2020, 2:33 PMImmutableList
. That means that no matter what the underlying object is, it cannot be changed.loke
10/25/2020, 2:33 PMAlina Dolgikh [JB]
user
10/26/2020, 11:48 AMGayan Perera
10/26/2020, 9:08 PMnodes\icon_name.svg
works. What should i used with kotlin icon names ?user
10/27/2020, 11:13 AMuser
10/27/2020, 2:32 PMVivek Sharma
10/27/2020, 7:12 PMRob Elliot
10/28/2020, 11:26 AMuser
10/29/2020, 10:21 AMursus
10/29/2020, 9:38 PMuser
10/30/2020, 9:16 AMuser
10/30/2020, 1:30 PMAnimesh Sahu
10/31/2020, 5:27 AMTwferrell
11/01/2020, 12:50 AMYogeshkolte
11/01/2020, 4:16 AMuser
11/02/2020, 2:12 PMNikky
11/02/2020, 7:04 PMmaven-publish
to mavenLocal()
but when using the library from a jvm project libname-jvm
and navigate to definition idea is unable to attach sources it seems
Posted in #multiplatformkvs
11/03/2020, 4:54 AMBart
11/03/2020, 7:45 AMdagguh
11/03/2020, 8:42 AM@since 1.2.3
to the primary constructor KDoc?