'Apply state to self if self is not symbolic and state is a FockStateKet, else
multiply self by state.
Examples
>>> from sympy.physics.secondquant import B, Dagger, BKet
>>> from sympy.abc import x, y, n
>>> Dagger(B(x)).apply_operator(y)
y*CreateBoson(x)
>>> B(0).apply_operator(BKet((n,)))
sqrt(n)*FockStateBosonKet((n - 1,))'

def apply_operator(self, state):

    if isinstance(state, FockStateFermionKet):
        element = self.state
        return state.up(element)
    elif isinstance(state, Mul):
        (c_part, nc_part) = state.args_cnc()
        if isinstance(nc_part[0], FockStateFermionKet):
            element = self.state
            return Mul(*((c_part + [nc_part[0].up(element)]) + nc_part[1:]))
    return Mul(self, state)
