Select with predicate

implemented select with predicate. I think it is right, but there is an
error in the printout which may be due to the other select function.