Guest User

Untitled

a guest
Jul 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. FUNGIBLE = [:coin, :coin, :coin, :coin]
  2. INFUNGIBLE = [:coin, :cow, :wine, :kebab]
  3. # Is each unit in the list of assets interchangeable?
  4. def fungible?(assets)
  5. if assets.all?{ |unit| assets.all? {|other_unit| unit==other_unit }}
  6. puts "#{assets.inspect} is fungible"
  7. else
  8. puts "#{assets.inspect} is not fungible"
  9. end
  10. end
  11.  
  12. fungible?(FUNGIBLE)
  13. # [:coin, :coin, :coin, :coin] is fungible
  14.  
  15. fungible?(INFUNGIBLE)
  16. # [:coin, :cow, :wine, :kebab] is not fungible
Add Comment
Please, Sign In to add comment