(self, state)
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,))
Apply state to self if self is not symbolic and state is a FockStateKet, else
        multiply self by state.
Apply state to self if self is not symbolic and state is a FockStateKet else multiply self by state .
def apply_operator(self, state):
        """
        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,))
        """
        if isinstance(state, FockStateFermionKet):
            element = self.state
            return state.down(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].down(element)] + nc_part[1:]))
            else:
                return Mul(self, state)

        else:
            return Mul(self, state)
def apply_operator ( self , state ) : if isinstance ( state , FockStateFermionKet ) : element = self . state return state . down ( 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 ] . down ( element ) ] + nc_part [ 1 : ] ) ) else : return Mul ( self , state ) else : return Mul ( self , state )