def repeated_permutation(n = @size)
      return enum_for(:repeated_permutation, n) if not block_given?
      if n < 0
        # yield nothing
      elsif n == 0
        yield []
      elsif n == 1
        each { |element| yield [element] }
      else
        result = []
        perms = lambda do |index|
          0.upto(@size-1) do |i|
            result[index] = get(i)
            if index < n-1
              perms[index+1]
            else
              yield result.dup
            end
          end
        end
        perms[0]
      end
      return self
    end
def repeated_permutation(n = @size)
      return enum_for(:repeated_permutation, n) if not block_given?
      if n < 0
        # yield nothing
      elsif n == 0
        yield []
      elsif n == 1
        each { |element| yield [element] }
      else
        result = []
        perms = lambda do |index|
          0.upto(@size-1) do |i|
            result[index] = get(i)
            if index < n-1
              perms[index+1]
            else
              yield result.dup
            end
          end
        end
        perms[0]
      end
      return self
    end
When invoked with a block, yields all repeated permutations of length `n` of
 elements from the `Tuple`, and then returns `self`. A "repeated permutation" is
 one where any element from the `Tuple` can appear any number of times, and in
 any position (not just consecutively)

 If no length `n` is specified, permutations of all elements will be yielded.
 There is no guarantee about which order the permutations will be yielded in.

 If no block is given, an `Enumerator` is returned instead.

 @example
   t = Erlang::Tuple[5, 6, 7]
   t.repeated_permutation(2) { |p| puts "Permutation: #{p}" }

   Permutation: [5, 5]
   Permutation: [5, 6]
   Permutation: [5, 7]
   Permutation: [6, 5]
   Permutation: [6, 6]
   Permutation: [6, 7]
   Permutation: [7, 5]
   Permutation: [7, 6]
   Permutation: [7, 7]
   # => Erlang::Tuple[5, 6, 7]

 @return [self, Enumerator]