From e496b95881dffa3eda352cec6aa3249c6062d40a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 25 Nov 2018 16:19:17 +0000 Subject: Subset and superset operators for `bit_set`: < <= > >= --- examples/demo/demo.odin | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'examples') diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index 1a4b48037..b1aa4e12d 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -814,6 +814,21 @@ bit_set_type :: proc() { y |= {1, 4, 2}; assert(2 in y); } + { + Letters :: bit_set['A'..'Z']; + a := Letters{'A', 'B'}; + b := Letters{'A', 'B', 'C', 'D', 'F'}; + c := Letters{'A', 'B'}; + + + assert(a <= b); // 'a' is a subset of 'b' + assert(b >= a); // 'b' is a superset of 'a' + assert(a < b); // 'a' is a strict subset of 'b' + assert(b > a); // 'b' is a strict superset of 'a' + + assert(!(a < c)); // 'a' is a not strict subset of 'c' + assert(!(c > a)); // 'c' is a not strict superset of 'a' + } } diverging_procedures :: proc() { -- cgit v1.2.3