Skip to content

Instantly share code, notes, and snippets.

@onli
Created March 4, 2017 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onli/4a9aff9a1b3fde3cea79cd323ac669a5 to your computer and use it in GitHub Desktop.
Save onli/4a9aff9a1b3fde3cea79cd323ac669a5 to your computer and use it in GitHub Desktop.
require './maybeOrderedList.rb'
mol = MaybeOrderedList.new()
itemsA = [['a', 10], ['c', 1], ['b', 5]]
itemsA.each do |item, value|
mol.add(item, value)
end
puts 'mol'
mol.each {|x| puts "#{x.subitem} #{x.weight}" }
molB = MaybeOrderedList.new()
itemsB = [['a', 10], ['d', 9], ['e', 20]]
itemsB.each do |item, value|
molB.add(item, value)
end
puts 'molB'
molB.each {|x| puts "#{x.subitem} #{x.weight}" }
mol = mol + molB
puts "merge"
mol.each {|x| puts "#{x.subitem} #{x.weight}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment