RosettaCodeData/Task/Set/Sidef/set-2.sidef

23 lines
627 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
var x = MySet(1, 2, 3)
5..7 -> each { |i| x += i }
2016-12-05 23:44:36 +01:00
2019-09-12 10:33:56 -07:00
var y = MySet(1, 2, 4, x)
2016-12-05 23:44:36 +01:00
2019-09-12 10:33:56 -07:00
say "set x is: #{x}"
say "set y is: #{y}"
2016-12-05 23:44:36 +01:00
[1,2,3,4,x].each { |elem|
2019-09-12 10:33:56 -07:00
say ("#{elem} is ", elem ∈ y ? '' : 'not', " in y")
2016-12-05 23:44:36 +01:00
}
2019-09-12 10:33:56 -07:00
var (w, z)
say ("union: ", x y)
say ("intersect: ", x ∩ y)
say ("z = x y = ", z = (x y) )
say ("y is ", x ⊆ y ? "" : "not ", "a subset of x")
say ("z is ", x ⊆ z ? "" : "not ", "a subset of x")
say ("z = (x y) (x ∩ y) = ", z = ((x y) (x ∩ y)))
say ("w = x ^ y = ", w = (x ^ y))
say ("w is ", w ≡ z ? "" : "not ", "equal to z")
say ("w is ", w ≡ x ? "" : "not ", "equal to x")