aboutsummaryrefslogtreecommitdiff
path: root/test/sets.tm
blob: b30c2ce3aaa3ee0369fac6baac3ccbc58c7feb95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

func main()
    t1 := @|10, 20, 30, 10|
    >> t1[]
    = |10, 20, 30|
    >> t1.has(10)
    = yes
    >> t1.has(-999)
    = no

    >> t2 := |30, 40|

    >> t1.with(t2)
    >> |10, 20, 30, 40|

    >> t1.without(t2)
    >> |10, 20|

    >> t1.overlap(t2)
    >> |30|


    >> |1,2|.is_subset_of(|2,3|)
    = no
    >> |1,2|.is_subset_of(|1,2,3|)
    = yes
    >> |1,2|.is_subset_of(|1,2|)
    = yes
    >> |1,2|.is_subset_of(|1,2|, strict=yes)
    = no

    >> t1.add_all(t2)
    >> t1[]
    = |10, 20, 30, 40|
    >> t1.remove_all(t2)
    >> t1[]
    = |10, 20|

    >> |3, i for i in 5|
    = |3, 1, 2, 4, 5|

    >> empty : |Int| = ||
    = ||

    >> |1,2,3| or |3,4|
    = |1,2,3,4|
    >> |1,2,3| and |3,4|
    = |3|
    >> |1,2,3| xor |3,4|
    = |1,2,4|
    >> |1,2,3| - |3,4|
    >> |1,2|