Bart Kleijngeld
03/22/2022, 2:56 PMSet<X> collections, and I want to see if they contain equal items. The challenge is that this equality must be tested by some external isomorphic function (which takes two arguments of type X) instead of the standard equality operator.
Can someone point towards helpful ideas or tools in Kotlin/Arrow?Bart Kleijngeld
03/22/2022, 2:57 PMall to force equality by the isomorphic function.
I'm not sure if that's the best option though. Moreover, I can't seem to find anything in Arrow or Kotlin to perform a Cartesian product (like Python's itertools.product)Robert Menke
03/22/2022, 3:00 PMBart Kleijngeld
03/22/2022, 3:01 PMisomorphic, not ==.Robert Menke
03/22/2022, 3:06 PMBart Kleijngeld
03/22/2022, 3:08 PMtrue if it deems two elements equal, and false otherwiseRobert Menke
03/22/2022, 3:09 PMBart Kleijngeld
03/22/2022, 3:11 PMList)Bart Kleijngeld
03/22/2022, 3:20 PMA is a subset of B , so that doesn't suffice, but:
setA.all { a -> setB.any { b -> isomorphic(a, b) } } // should be trueRobert Menke
03/22/2022, 3:21 PMBart Kleijngeld
03/22/2022, 3:22 PMRobert Menke
03/22/2022, 3:22 PMRobert Menke
03/22/2022, 3:22 PMRobert Menke
03/22/2022, 3:23 PMBart Kleijngeld
03/22/2022, 3:23 PMRobert Menke
03/22/2022, 3:27 PMRobert Menke
03/22/2022, 3:29 PMfun <T> Set<T>.containsAllIsomorphic(other: Set<T>) = this.all { a -> other.any { b -> isomorphic(a, b)} }
fun <T> Set<T>.isInjective(other: Set<T>) = this.containsAll(other) && other.containsAll(this)Robert Menke
03/22/2022, 3:30 PMBart Kleijngeld
03/22/2022, 3:31 PMBart Kleijngeld
03/22/2022, 3:31 PMRobert Menke
03/22/2022, 3:34 PMBart Kleijngeld
03/22/2022, 3:46 PMRobert Menke
03/22/2022, 3:52 PM