Jakub Pi
03/25/2020, 12:55 AMfun sameSize(left : Data, right : Data) : Boolean = left.size == right.size
fun equal(left : Data, right : Data) : Boolean = left == right
fun hashMatches(left : Data, right : Data) : Boolean = left.hash == right.hash
fun pHashMatches(left : Data, right : Data) : Boolean = left.phash == right.phash
fun partial(data : Data, func : (Data, Data) -> Boolean) : (Data) -> Boolean = {
func(data, it)
}
val predicates = listOf(
partial(realised, ::sameSize),
partial(realised, ::hashMatches)
)
structure.filter{ predicates.fold(true) {acc, func -> func(it) && acc} }
This is what I have so far, how can I improve this? Also, I would ideally traverse the structure only once (admittedly splitting processing across each subset).. not sure how to go about this. I already have arrow in the project so solutions in that are also welcome.