You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
565 B
24 lines
565 B
1 month ago
|
require_relative 'lib/array_processor'
|
||
|
|
||
|
|
||
|
processor = ArrayProcessor.new([1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||
|
|
||
|
# chunk
|
||
|
puts "Chunk example:"
|
||
|
p processor.chunk { |x| x.even? }
|
||
|
|
||
|
# include?
|
||
|
puts "Include example (5): #{processor.include?(5)}"
|
||
|
puts "Include example (10): #{processor.include?(10)}"
|
||
|
|
||
|
# reduce
|
||
|
puts "Reduce example (sum): #{processor.reduce(0) { |acc, x| acc + x }}"
|
||
|
|
||
|
# member?
|
||
|
puts "Member example (5): #{processor.member?(5)}"
|
||
|
puts "Member example (10): #{processor.member?(10)}"
|
||
|
|
||
|
# filter
|
||
|
puts "Filter example (odd numbers):"
|
||
|
p processor.filter { |x| x.odd? }
|