sourcelibs/Sets/demos/clubs.xtl
1⍝!/usr/bin/env xetal
2⍝# Clubs: who is in which club, as sets of names. Run with "just demo Sets clubs".
3
4ˢᵉ⁼u̲se< "Sets"
5ᵗ⁼u̲se< "Strings"
6chess ← "ana" "ben" "cy" "dee"
7drama ← "ben" "eve" "dee" "fay"
8choir ← "gus" "eve"
9
10", " ᵗj̲oin chess ˢᵉi̲ntersect drama ⍝ in chess and drama
11", " ᵗj̲oin chess ˢᵉs̲ymmetric drama ⍝ in exactly one of the two
12", " ᵗj̲oin (chess ˢᵉu̲nion drama) ˢᵉu̲nion choir ⍝ everyone
13choir ˢᵉd̲isjoint? chess ⍝ no chess player sings
14
15⍝ How many clubs each person is in.
16all ← chess c̲at drama c̲at choir
17"\n" ᵗj̲oin '{ i → (5 ᵗp̲adRight d̲isclose i s̲elect u̲nique all) c̲at f̲ormat i s̲elect ˢᵉc̲ounts all } m̲ap r̲ange t̲ally u̲nique all