Generalize select.

Generalize the select into a fold operation which can be used to join
two lattices into one.