From conversation on F# discord: https://discord.com/channels/196693847965696000/1109160345316098058
So first off, I converted the input type to list<'a * Set<'b>>
instead of list<'a * list<'b>>
for now to make some of the implementation clearer, but we can change the types back later if you want.
Okay, so with any complex problem we don't know how to solve, we should break it down into smaller pieces that we can solve. So at the root of this, we need to be able to compare two elements of the input list and if their sets share any elements, return the first part of each element. So if we write a function to do this, it is going to need to return an option<'a * 'a>
, since for some inputs we want to return a 'a * 'a
, but for other inputs we won't.
let compareElements
(this: 'a, these: Set<'b>)
(that: 'a, those: Set<'b>)
: option<'a * 'a> =