I am on work, so can't access my home laptop. But this problem is related to pairing functions (but those work for the whole domain of the naturals). It means you need to find a function that walks the numbers in a nice way, like seen here: http://szudzik.com/ElegantPairing.pdf
I think it isn't possible to find a function that works for arbitrary sequences. I know there is a function that works if the sets have the same size (n is size), it is trivial why those work. They have the form n^0 a + n^1 b, where a,b are in [1..n]:
f :: Integer -> (Integer,Integer) -> Integer
f n (i,j) = i + (j - 1)*n
-- For example:
f 3 <$> ((,) <$> [1..3] <*> [1..3])
[1,4,7,2,5,8,3,6,9]
Now I want to find functions like (n,m is size, n /= m):
f n m (i,j) = ..
And functions where n maybe chosen but m is between certain bounds. I have found a couple of those by mutilating pairing functions.
I know I can use a counter, but I don't like cheating :p
I need to draw your reasoning on a paper to see it or take some time for it. Little bit busy, working from home, having the kids and stuff :p
I think it isn't possible to find a function that works for arbitrary sequences. I know there is a function that works if the sets have the same size (n is size), it is trivial why those work. They have the form n^0 a + n^1 b, where a,b are in [1..n]:
Now I want to find functions like (n,m is size, n /= m): And functions where n maybe chosen but m is between certain bounds. I have found a couple of those by mutilating pairing functions.I know I can use a counter, but I don't like cheating :p
I need to draw your reasoning on a paper to see it or take some time for it. Little bit busy, working from home, having the kids and stuff :p