I have two long lists (of different lengths) of complex numbers. There seem to be some close pairings, so I'd like to explicitly pair elements from each list with their nearest counterpart in the other list.
Example, with small Reals for simplicity:
a={0.13, 0.83, 0.79, 0.61, 0.91, 0.99, 0.4};
b={0.72, 0.02, 0.69, 0.37, 0.14};
For this example, I'd like to pair these up by Min[Abs[a[[i]]-b[[j]]]]
where Abs[a[[i]]-b[[j]]]<.1
Desired result:
$$ \left( \begin{array}{c} \{0.13,0.4,0.61,0.79\} \\ \{0.14,0.37,0.69,0.72\} \\ \{0.83,0.91,0.99\} \\ \{0.02\} \\ \end{array} \right) $$
The first two rows match the respective matching elements from a and b. The 3rd and 4th rows are the unmatched elements from respectively a and b.
Is there some way to do this efficiently with Mathematica functions?