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