<commit_before>require 'enumerable'

class PrimeGenerator
  include Enumerable

  def each
    composites = {}
    def composites.combine!(hash) 
      merge!(hash) do |key,x,y|
        x.push(y.shift) while y.any?; x
      end
    end

    n = 2
    while true
      unless composites.has_key?(n)
        composites.combine!(n**2 => [n])
        yield n
      else
        factors = composites[n]
        factors.each { |factor| composites.combine!(n + factor => [factor]) }
        composites.delete(n)
      end
      n += 1
    end
  end
end<commit_msg>simplified handling of composites hash<commit_after>require 'enumerable'

class PrimeGenerator
  include Enumerable

  def each
    composites = {}
    n = 2
    while true
      if composites.has_key?(n)
        factors = composites[n]
        factors.each { |factor| composites.merge!(n + factor => [factor]) { |key,left,right| left + right } }
        composites.delete(n)
      else
        composites.merge!(n**2 => [n]) { |key,left,right| left + right }
        yield n
     end
      n += 1
    end
  end
end
{'fraction_non_alphanumeric': 0.11380597014925373, 'fraction_numerical': 0.005597014925373134, 'mean_word_length': 2.2222222222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6053904', 'n_tokens_mistral': 355, 'n_tokens_neox': 342, 'n_words': 88}