Eliminate COND from nested loop.

Doing a COND on each selector for each row is going to be slow, so this code converts them all to functions once, and then applies the functions using nested MAPs. Added a test function.