1 import Base 2 import ./type.bend as I 3 4 def owns.go(xs: List<&2, I.Device>, +key: String, +name: String) -> Bool: 5 match xs: 6 case []: 7 False{} 8 case I.Device{+k, +n, _} <> rest: 9 (String.eq(key, k) && String.eq(name, n)) || owns.go(rest, key, name) 10 11 # Whether the owner has the device with this key, under this name. 12 def owns(inv: I.Inventory, +key: String, +name: String) -> Bool: 13 match inv: 14 case I.Inventory{_, devices}: 15 owns.go(devices, key, name) 16 17 # Whether this provider is the owner's vendor's cloud. 18 def cloud_ok(inv: I.Inventory, +provider: String) -> Bool: 19 match inv: 20 case I.Inventory{I.Vendor{_, cloud}, _}: 21 String.eq(provider, cloud)