Sha256: 4dd1e42569b872bba723e3fd51711ef936274432a9741eb5c8af1ca82ecaef34

Contents?: true

Size: 342 Bytes

Versions: 34

Compression:

Stored size: 342 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# encoding=utf-8

module ArrayUtil
  def self.partition_by_predicate(arr)
    true_list = []
    false_list = []

    arr.each do |element|
      if yield(element)
        true_list << element
      else
        false_list << element
      end
    end

    [true_list, false_list]
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
markdown_exec-2.7.2 lib/array_util.rb
markdown_exec-2.7.1 lib/array_util.rb
markdown_exec-2.7.0 lib/array_util.rb
markdown_exec-2.6.0 lib/array_util.rb
markdown_exec-2.5.0 lib/array_util.rb
markdown_exec-2.4.0 lib/array_util.rb
markdown_exec-2.3.0 lib/array_util.rb
markdown_exec-2.2.0 lib/array_util.rb
markdown_exec-2.1.0 lib/array_util.rb
markdown_exec-2.0.8.4 lib/array_util.rb
markdown_exec-2.0.8.3 lib/array_util.rb
markdown_exec-2.0.8.2 lib/array_util.rb
markdown_exec-2.0.8.1 lib/array_util.rb
markdown_exec-2.0.8 lib/array_util.rb
markdown_exec-2.0.7 lib/array_util.rb
markdown_exec-2.0.6 lib/array_util.rb
markdown_exec-2.0.5 lib/array_util.rb
markdown_exec-2.0.4 lib/array_util.rb
markdown_exec-2.0.3.2 lib/array_util.rb
markdown_exec-2.0.3.1 lib/array_util.rb