3 gSum :: Additive a => [a] -> <Proc> a
4 gSum list = getRef answer
11 -El ?x, -El ?y => El (?x + ?y)
14 main = (gSum [1,6,9], gSum [1.0,6.0,9.0])
18 import "StandardLibrary"
20 topologicalSort :: [(a,a)] -> <Proc> [a]
21 topologicalSort dependencies = MList.freeze answer
23 answer = MList.create ()
25 (?x,?y) <- dependencies => Dep ?x ?y, InDegree ?x 0, InDegree ?y 1
26 -InDegree ?x ?a, -InDegree ?x ?b => InDegree ?x (?a + ?b)
27 InDegree ?x 0 => AdjustInDegrees ?x, MList.add answer ?x
28 AdjustInDegrees ?x, Dep ?x ?y => InDegree ?y (-1)
30 main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]
34 import "StandardLibrary"
36 topologicalSort :: Show a => [(a,a)] -> <Proc> [a]
37 topologicalSort dependencies = MList.freeze answer
39 answer = MList.create ()
41 -Candidate ?x, Candidate ?x => True
42 (?x,?y) <- dependencies => Dep ?x ?y, Candidate ?x
43 -Candidate ?x, Dep _ ?x => True
44 Candidate ?x => MList.add answer ?x
45 Candidate ?x, -Dep ?x ?y => Candidate ?y
47 main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]