def __iter__(self):
        """
        EXAMPLES::

            sage: IntegerVectors(-1, 0, min_part = 1).list()
            []
            sage: IntegerVectors(-1, 2, min_part = 1).list()
            []
            sage: IntegerVectors(0, 0, min_part=1).list()
            [[]]
            sage: IntegerVectors(3, 0, min_part=1).list()
            []
            sage: IntegerVectors(0, 1, min_part=1).list()
            []
            sage: IntegerVectors(2, 2, min_part=1).list()
            [[1, 1]]
            sage: IntegerVectors(2, 3, min_part=1).list()
            []
            sage: IntegerVectors(4, 2, min_part=1).list()
            [[3, 1], [2, 2], [1, 3]]

        ::

            sage: IntegerVectors(0, 3, outer=[0,0,0]).list()
            [[0, 0, 0]]
            sage: IntegerVectors(1, 3, outer=[0,0,0]).list()
            []
            sage: IntegerVectors(2, 3, outer=[0,2,0]).list()
            [[0, 2, 0]]
            sage: IntegerVectors(2, 3, outer=[1,2,1]).list()
            [[1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1]]
            sage: IntegerVectors(2, 3, outer=[1,1,1]).list()
            [[1, 1, 0], [1, 0, 1], [0, 1, 1]]
            sage: IntegerVectors(2, 5, outer=[1,1,1,1,1]).list()
            [[1, 1, 0, 0, 0],
             [1, 0, 1, 0, 0],
             [1, 0, 0, 1, 0],
             [1, 0, 0, 0, 1],
             [0, 1, 1, 0, 0],
             [0, 1, 0, 1, 0],
             [0, 1, 0, 0, 1],
             [0, 0, 1, 1, 0],
             [0, 0, 1, 0, 1],
             [0, 0, 0, 1, 1]]

        ::

            sage: iv = [ IntegerVectors(n,k) for n in range(-2, 7) for k in range(7) ]
            sage: all(map(lambda x: x.cardinality() == len(x.list()), iv))
            True
            sage: essai = [[1,1,1], [2,5,6], [6,5,2]]
            sage: iv = [ IntegerVectors(x[0], x[1], max_part = x[2]-1) for x in essai ]
            sage: all(map(lambda x: x.cardinality() == len(x.list()), iv))
            True
        """
        return integer_list.iterator(self.n, *self._parameters())
Esempio n. 2
0
 def __iter__(self):
     """
     EXAMPLES::
     
         sage: IntegerVectors(-1, 0, min_part = 1).list()
         []
         sage: IntegerVectors(-1, 2, min_part = 1).list()
         []
         sage: IntegerVectors(0, 0, min_part=1).list()
         [[]]
         sage: IntegerVectors(3, 0, min_part=1).list()
         []
         sage: IntegerVectors(0, 1, min_part=1).list()
         []
         sage: IntegerVectors(2, 2, min_part=1).list()
         [[1, 1]]
         sage: IntegerVectors(2, 3, min_part=1).list()
         []
         sage: IntegerVectors(4, 2, min_part=1).list()
         [[3, 1], [2, 2], [1, 3]]
     
     ::
     
         sage: IntegerVectors(0, 3, outer=[0,0,0]).list()
         [[0, 0, 0]]
         sage: IntegerVectors(1, 3, outer=[0,0,0]).list()
         []
         sage: IntegerVectors(2, 3, outer=[0,2,0]).list()
         [[0, 2, 0]]
         sage: IntegerVectors(2, 3, outer=[1,2,1]).list()
         [[1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1]]
         sage: IntegerVectors(2, 3, outer=[1,1,1]).list()
         [[1, 1, 0], [1, 0, 1], [0, 1, 1]]
         sage: IntegerVectors(2, 5, outer=[1,1,1,1,1]).list()
         [[1, 1, 0, 0, 0],
          [1, 0, 1, 0, 0],
          [1, 0, 0, 1, 0],
          [1, 0, 0, 0, 1],
          [0, 1, 1, 0, 0],
          [0, 1, 0, 1, 0],
          [0, 1, 0, 0, 1],
          [0, 0, 1, 1, 0],
          [0, 0, 1, 0, 1],
          [0, 0, 0, 1, 1]]
     
     ::
     
         sage: iv = [ IntegerVectors(n,k) for n in range(-2, 7) for k in range(7) ]
         sage: all(map(lambda x: x.cardinality() == len(x.list()), iv))
         True
         sage: essai = [[1,1,1], [2,5,6], [6,5,2]]
         sage: iv = [ IntegerVectors(x[0], x[1], max_part = x[2]-1) for x in essai ]
         sage: all(map(lambda x: x.cardinality() == len(x.list()), iv))
         True
     """
     return integer_list.iterator(self.n, *self._parameters())