Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment