<commit_before>module PrimeFinder

  # I deliberated for a while on whether to use a class or an object for this.
  # I decided that since these are purely behavioural helper methods and nothing
  # is instantiated, it make more sense to be a module.

  module_function

  # I wanted to find as simple as possible a way to find all primes and
  # then to store the primes in an array. Whilst initially I wanted to
  # have a prime? method, followed by a method which iterates over a range
  # and stores the prime numbers in an array, in the course of the refactoring
  # process I realised that it is possible to do both.

  def find_primes(n)
    inf = Float::INFINITY

    primes = (2..inf).lazy.select do |i|
      (2...i).none? {|x| i % x == 0  }
    end

    primes.first(n)
  end

  # As you can see, the method uses the Lazy emunerator class method
  # to iterate up to infinity, but without impacting performance. It is
  # then simply a case of collecting the desired number of primes into an
  # array.

  def times_primes(n)
    primes = find_primes(n)
    primes.unshift(1)
    primes.map { |prime1| primes.map {|prime2| prime2 * prime1 } }
  end

  # This method multiplies the primes together in order to generate an array
  # of the multiplied values. This is then fed into the executable to generate
  # matrices.

  # I stacked the map functions to make it more efficient.

end

def find_primes(n)
  inf = Float::INFINITY

  primes = (2..inf).lazy.select do |i|
    (2...i).none? {|x| i % x == 0  }
  end

  primes.first(n)
end
<commit_msg>fix accidental commit<commit_after>module PrimeFinder

  # I deliberated for a while on whether to use a class or an object for this.
  # I decided that since these are purely behavioural helper methods and nothing
  # is instantiated, it make more sense to be a module.

  module_function

  # I wanted to find as simple as possible a way to find all primes and
  # then to store the primes in an array. Whilst initially I wanted to
  # have a prime? method, followed by a method which iterates over a range
  # and stores the prime numbers in an array, in the course of the refactoring
  # process I realised that it is possible to do both.

  def find_primes(n)
    inf = Float::INFINITY

    primes = (2..inf).lazy.select do |i|
      (2...i).none? {|x| i % x == 0  }
    end

    primes.first(n)
  end

  # As you can see, the method uses the Lazy emunerator class method
  # to iterate up to infinity, but without impacting performance. It is
  # then simply a case of collecting the desired number of primes into an
  # array.

  def times_primes(n)
    primes = find_primes(n)
    primes.unshift(1)
    primes.map { |prime1| primes.map {|prime2| prime2 * prime1 } }
  end

  # This method multiplies the primes together in order to generate an array
  # of the multiplied values. This is then fed into the executable to generate
  # matrices.

  # I stacked the map functions to make it more efficient.

end

{'fraction_non_alphanumeric': 0.06691324815063887, 'fraction_numerical': 0.006388702084734364, 'mean_word_length': 3.0476190476190474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2181824', 'n_tokens_mistral': 932, 'n_tokens_neox': 879, 'n_words': 434}