SetsTest.cm
Last tweaked by Mike Spreitzer on March 8, 1988 9:08:58 am PST
Install SetsAndStuff
state
{ OPEN IntStuff, SetBasics, Sets:AbSets, Sets, BiRelBasics, BiRels; NULL}
{ alwaysAdd: IfHadPair ~ ALL[ALL[TRUE]]; NULL}
← &r1 ← CreateHashReln[ALL[refs], ALL[TRUE], ALL[TRUE]]
← &r1.class.AddPair[&r1, [[ra:$foo], [ra:$bar]], alwaysAdd]
← &s1 ← Sets.NCreateSingleton[[ra:$foo], refs]
← &i1 ← &r1.class.Image[&r1, &s1, leftToRight]
← &r1.class.AddPair[&r1, [[ra:$bar], [ra:$gronk]], alwaysAdd]
← &r1.class.AddPair[&r1, [[ra:$gronk], [ra:$foo]], alwaysAdd]
← &r1.class.AddPair[&r1, [[ra:$zot], [ra:NIL]], alwaysAdd]
← &r1
← &c1 ← Compose[&r1, &r1, ALL[FALSE]]
← &r2 ← CreateList[NIL, [TRUE, FALSE], ALL[refs], variable, [ALL[fwd]], FALSE]
← &r2.class.AddPair[&r2, [[ra:$foo], [ra:$zoo]], alwaysAdd]
← &r2.class.AddPair[&r2, [[ra:$bar], [ra:$baz]], alwaysAdd]
← &r2.class.AddPair[&r2, [[ra:$baz], [ra:$foo]], alwaysAdd]
← &r2.class.AddPair[&r2, [[ra:$zoo], [ra:$bar]], alwaysAdd]
← &r2
← &r2.class.AddPair[&r2, [[ra:$bar], [ra:$oof]], alwaysAdd]
← &r2
← &l1 ← Sets.CreateList[LIST[[i:10], [i:30], [i:20]], ints, variable, fwd]
← &l1.class.AddSet[&l1, Sets.NCreateSingleton[[i:15], ints]]
← &l1
← &l1.class.AddSet[&l1, Sets.NCreateSingleton[[i:20], ints]]
← &l1
← &v1 ← CreateVector[bounds: [0, 9], val: [ra:$foo], rightSpace: refs]
← &v1.class.AddPair[&v1, [[i:3], [ra:$bar]], alwaysAdd]
← &v1.class.AddPair[&v1, [[i:13], [ra:$bar]], alwaysAdd]
← &v1.class.RemPair[&v1, [[i:5], [ra:$foo]]]
← &v1.class.RemPair[&v1, [[i:4], [ra:$zork]]]
← &v1.class.RemPair[&v1, [[i:40], [ra:$zork]]]
← &v1
← &v1.class.Image[&v1, IIAsSet[[0, 20]], leftToRight]
← &sr ← &v1.class.SetOn[&v1, right]
← &sr.class.Get3[&sr, [$foo], [TRUE, TRUE, TRUE]]
← &sr.class.HasMember[&sr, [$foo]]
← &sr.class.HasMember[&sr, [$baz]]
← &v1.class.AddPair[&v1, [[i:11], [ra:NIL]], alwaysAdd]
← &allints ← IntervalAsSet[ints, ALL[noValue]]
← &nil ← Sets.NCreateSingleton[[NIL], refs]
← &v1.class.ScanRestriction[&v1, [&allints, &nil], AcceptAny, [ALL[no]]]
← &l2 ← Sets.CreateList[LIST[[ra:"y"], [ra:"x"], [ra:"z"]], ropes[TRUE], variable, no]
← EnumSeqOfSet[&l2, fwd]
← EnumSeqOfSet[&l2, bwd]
← &s2 ← EnumSeqOfSet[&l2, no]
← &s2.class.GetBounds[&s2, ALL[TRUE], [ALL[fwd]]]!!!
← &l2.class.AddSet[&l2, Sets.NCreateSingleton[[ra:"xyz"], ropes[TRUE]]]
← &l2
← &s2
← &p1 ← GradeUp[&s2, [ropes[TRUE].Compare, ropes[TRUE].data]]
← &s3 ← CreateVector[val: noValue, rightSpace: ropes[TRUE]]
← TransPermute[&s2, &s3, &p1]
← &s3
← &s2b ← CreateVectorCopy[of: &s2, rightSpace: ropes[TRUE]]
← PermuteInPlace[&s2b, &p1]
← &s2b
← &rb1 ← CreateRedBlackTable[[ropes[TRUE], refs]]
← &rb1.class.AddPair[&rb1, [[ra:"bar"], [ra:$bar]], alwaysAdd]
← &rb1
← &rb1.class.AddPair[&rb1, [[ra:"bar"], [ra:$Bar]], alwaysAdd]
← &rb1.class.AddPair[&rb1, [[ra:"Bar"], [ra:$Bar]], alwaysAdd]
← &rb1.class.Apply[&rb1, [ra:"bar"], leftToRight]
← &rb1.class.Apply[&rb1, [ra:"zork"], leftToRight]
← &rb1.class.Delete[&rb1, [ra:"bar"], left]
← &rb1.class.Delete[&rb1, [ra:"bork"], left]
← &rb1.class.RemPair[&rb1, [[ra:"bar"], [ra:$Boff]]]
← &ht1 ← CreateHashTable[ALL[refs]]
← &ht1.class.AddPair[&ht1, [[ra:$bar], [ra:$rab]], alwaysAdd]
← &ht1.class.AddPair[&ht1, [[ra:$foo], [ra:$oof]], alwaysAdd]
← &ht1
← BiRels.Primitive[&ht1, $ScanRestriction, NIL, BiRels.FromRO[[[fwd, no], left]]]
← &ht1.class.GetOne[&ht1, FALSE, [[fwd, no], left]]
← &s4 ← CreateHashSet[refs]
← NAddElt[&s4, [ra:$foo]]
← NAddElt[&s4, [ra:NIL]]
← NAddElt[&s4, [ra:$zork]]
← &s4
← NAddElt[&s4, [ra: $foo]]
← &s4
← &s4.class.RemSet[&s4, Sets.NCreateSingleton[[ra:$foo], refs]]
← &s4.class.RemSet[&s4, Sets.NCreateSingleton[[ra:$foo], refs]]
← &s4
← &ps1 ← WidenPairSpace[[[ints, refs], [ALL[fwd], left]]]
← &hps1 ← CreateHashSet[&ps1]!
← NAddElt[&hps1, [ra: NEW [Pair ← [[i:3], [ra:$foo]]]]]
← NAddElt[&hps1, [ra: NEW [Pair ← [[i:5], [ra:"5"]]]]]
← &hps1
← FormatSet[&hps1]
← &v2 ← CreateBitVector[bounds: [0, 32], expandable: FALSE]!
← NAddElt[&v2, [i: 5]]
← NAddElt[&v2, [i: 10]]
← NAddElt[&v2, [i: 16]]
← &v2
← &v2.class.Size[&v2, lastEINT]
← &v2.class.RemSet[&v2, IIAsSet[[10, 20]]]
← &v2
← &v2 ← CreateBitVector[bounds: [0, 32], expandable: TRUE]!
← NAddElt[&v2, [i: 5]]
← NAddElt[&v2, [i: 16]]
← &v2
← NAddElt[&v2, [i: -5]]
← NAddElt[&v2, [i: 35]]
← &v2
← &g1 ← GenCreate[spaces: [refs, ints], functional: ALL[FALSE], mappable: ALL[TRUE], hints: [[set: [class: $Vector, details: LIST[[$Bounds, NEW [IntInterval ← [0, 16]] ]] ]], [fn: [class: $Vector, details: LIST[[$Bounds, NEW [IntInterval ← [0, 16]] ]] ]] ]]
← &g1.class.AddPair[&g1, [[ra:$bar], [i:6]], alwaysAdd]
← &g1.class.AddPair[&g1, [[ra:$bar], [i:7]], alwaysAdd]
← &g1.class.AddPair[&g1, [[ra:$rab], [i:6]], alwaysAdd]
← &g1.class.AddPair[&g1, [[ra:$zit], [i:-6]], alwaysAdd]
← &g1
← &g1.class.Apply[&g1, [i:-6], rightToLeft]
← &g1.class.Apply[&g1, [i:7], rightToLeft]
← &g1.class.Apply[&g1, [i:8], rightToLeft]
← &base ← CreateVector[bounds: [0, 10], val: noValue, rightSpace: ints]
← &tfc ← &base.TransitiveFnClosure[TRUE]!
← &img ← &tfc.class.Image[&tfc, &v2, leftToRight]
← &base.AddNewII[1, 0]
← &base.AddNewII[2, 1]
← &base.AddNewII[3, 1]
← &base.AddNewII[4, 2]
← &base.AddNewII[5, 2]
← &base
← &tfc
← &img
← &tfc.class.HasPair[&tfc, [[i:1], [i:0]]]
← &tfc.class.HasPair[&tfc, [[i:0], [i:1]]]
← &base.AddNewII[0, 0]
← &tfc ← &base.TransitiveFnClosure[FALSE]
← &tfc.class.HasPair[&tfc, [[i:1], [i:0]]]
← &tfc.class.HasPair[&tfc, [[i:0], [i:1]]]
← &base.Substitute[[i:1], [i:7], right]
← &base