Created
December 10, 2010 20:00
-
-
Save pelle/736718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FUNGIBLE = [:coin, :coin, :coin, :coin] | |
INFUNGIBLE = [:coin, :cow, :wine, :kebab] | |
# Is each unit in the list of assets interchangeable? | |
def fungible?(assets) | |
if assets.all?{ |unit| assets.all? {|other_unit| unit==other_unit }} | |
puts "#{assets.inspect} is fungible" | |
else | |
puts "#{assets.inspect} is not fungible" | |
end | |
end | |
fungible?(FUNGIBLE) | |
# [:coin, :coin, :coin, :coin] is fungible | |
fungible?(INFUNGIBLE) | |
# [:coin, :cow, :wine, :kebab] is not fungible |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment