code: def bell_set(self, collection, ordinal=False):
          
          if len(collection) == 1:
              yield [ collection ]
              return
  
          first = collection[0]
          for smaller in self.bell_set(collection[1:]):
              for n, subset in enumerate(smaller):
                  if not ordinal or (ordinal and is_sorted(smaller[:n] + [[ first ] + subset] + smaller[n+1:], self._nan)):
                      yield smaller[:n] + [[ first ] + subset] + smaller[n+1:]
  
              if not ordinal or (ordinal and is_sorted([ [ first ] ] + smaller, self._nan)):
                  yield [ [ first ] ] + smaller
docs: Calculates the Bell set