Sha256: 219aaf9f825dbba8810c650f1b1e1e3076919a9a50d8b2cbeaf1beb07452679b
Contents?: true
Size: 1.08 KB
Versions: 396
Compression:
Stored size: 1.08 KB
Contents
class ListOps ## Do not use the functions map, concat, count, length, etc. ## and other built in ruby methods to solve these ## def self.arrays(arr) counter = 0 arr.each do counter += 1 end counter end def self.reverser(arr) answer = [] until arr.empty? answer << arr.pop end answer end def self.concatter(arr1, arr2) answer = [] arr1.each do |element| answer << element end arr2.each do |element| answer << element end answer end def self.mapper(arr) answer = [] arr.each do |element| answer << yield(element) if block_given? end answer end def self.filterer(arr) answer = [] arr.each do |element| answer << element if block_given? && yield(element) end answer end def self.sum_reducer(arr) total = 0 arr.each do |element| total += element end total end def self.factorial_reducer(arr) total = 1 arr.each do |element| total = total * element end total end end module BookKeeping VERSION = 2 end
Version data entries
396 entries across 396 versions & 1 rubygems