groostav
08/02/2024, 12:57 AMright.single { record.name == target } , because if target comes from a loop thats a full cartesian product, and the data sets of left & right could be a thousand or so elements long
but they are ordered, so right[n] must have a record in left that occurs before right[n+1]CLOVIS
08/02/2024, 7:30 AMval left = listOf(
CoolRecord("name1", emptyList()),
CoolRecord("name2", emptyList()),
CoolRecord("name3", emptyList()),
CoolRecord("name4", emptyList())
)
val right = listOf(
CoolRecord("name1", listOf(1.0, 2.0))
CoolRecord("name4", listOf(5.0, 6.0))
)CLOVIS
08/02/2024, 7:31 AMright ?
e.g. if I see name4 and I haven't yet seen name3 , can I assume it doesn't exist, or do I have to continue searching?groostav
08/02/2024, 6:09 PMval left = listOf(
CoolRecord("name1", emptyList()),
CoolRecord("name2", emptyList()),
CoolRecord("name3", emptyList()),
CoolRecord("name4", emptyList())
)
val right = listOf(
CoolRecord("name4" /*!!!*/, listOf(1.0, 2.0))
CoolRecord("name1", listOf(5.0, 6.0))
)groostav
08/02/2024, 6:10 PMright is sparseSam
08/05/2024, 9:19 AMfun reallySlickJoinFunction(
left: List<CoolRecord>,
right: List<CoolRecord>
): List<CoolRecord> {
var r = 0
return left.map {
if (it.name == right.getOrNull(r)?.name) right[r++] else it
}
}