extends vreduce to ternary functions