+module { export = [main], chr }
import "StandardLibrary"
-topologicalSort :: Show a => [(a,a)] -> <Proc> [a]
-topologicalSort dependencies = MList.freeze answer
- where
- answer = MList.create ()
+ruleset IntegerSet where
+ constraint Element Integer
+ // Set may not contain duplicates
+ Element ?x => print "added \(?x)"
+ -Element ?x, Element ?x => print "removed duplicate \(?x)"
- (?x,?y) <- dependencies => print "RULE 1, x=\(?x), y=\(?y)", Dep ?x ?y, InDegree ?x 0, InDegree ?y 1
- -InDegree ?x ?a, -InDegree ?x ?b => print "RULE 2, x=\(?x), a=\(?a), b=\(?b)", InDegree ?x (?a + ?b)
- InDegree ?x ?a => print "InDegree \(?x) \(?a)"
- InDegree ?x 0 => print "RULE 3, x=\(?x)", AdjustInDegrees ?x, MList.add answer ?x
- AdjustInDegrees ?x, Dep ?x ?y => print "RULE 4, x=\(?x), y=\(?y)", InDegree ?y (-1)
+addSet :: IntegerSet -> Integer -> <Proc> ()
+addSet set newElement = ()
+ where
+ include IntegerSet set
+ True => Element newElement
-main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]
+printSet :: IntegerSet -> <Proc> ()
+printSet set = ()
+ where
+ include IntegerSet set
+ Element ?x => print "printing \(?x)"
+
+main = ()
+ where
+ set = createIntegerSet
+ addSet set 1
+ addSet set 2
+ addSet set 1
+ printSet set
--
-[1, 3, 7, 2, 4]
\ No newline at end of file
+added 1
+added 2
+added 1
+removed duplicate 1
+printing 2
+printing 1
+()
\ No newline at end of file