The idealintersect command computes a basis for the intersection of A and B. The command uses the F4 algorithm for computing Groebner bases. An optional argument P is the modulus, which should be a machine size prime.
A = [(x-1)*y]; B = [y^2]; idealintersect(A,B); [-y^2+x*y^2]