Say you have a list:
L1 = [milk, butter, bread, shampoo, dog food] and you want to know how similar this list is to another list
L2 = [milk, butter, shampoo, dog food, coffee] That is get the union of two lists:
Result = L1 U L2 and Result is
[Milk, butter, dog food] Now, I know I can iterate over these and find the union. But given a list of size m and a list of size n. You will iterate this at least min(n, m) times. Given x lists, you have x^min(n,m) iterations which can get pricy.
I was thinking hashes could be the way, but I am not sure.
But if there was a way to minimize a list down to one string and compare it to another string.
that is H(L1) U H(L2) has x% in common?
Note that I don't actually need to know what were the items in common. Just that they have a percentage shared between the two.
setbuiltin? It's probably the data type for what you're after.