-import "Prelude"\r
-\r
-gSum :: Additive a => [a] -> <Proc> a\r
-gSum list = getRef answer\r
- where\r
- answer = ref zero\r
- \r
- constraint El a\r
- \r
- ?x <- list => El ?x\r
- -El ?x, -El ?y => El (?x + ?y)\r
- El ?x => answer := ?x\r
- \r
-main = (gSum [1,6,9], gSum [1.0,6.0,9.0]) \r
---\r
-(16,16.0)\r
---\r
-import "StandardLibrary"\r
-\r
-topologicalSort :: [(a,a)] -> <Proc> [a]\r
-topologicalSort dependencies = MList.freeze answer\r
- where\r
- answer = MList.create ()\r
- \r
- (?x,?y) <- dependencies => Dep ?x ?y, InDegree ?x 0, InDegree ?y 1\r
- -InDegree ?x ?a, -InDegree ?x ?b => InDegree ?x (?a + ?b)\r
- InDegree ?x 0 => AdjustInDegrees ?x, MList.add answer ?x\r
- AdjustInDegrees ?x, Dep ?x ?y => InDegree ?y (-1)\r
- \r
-main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]\r
---\r
-[1, 3, 7, 2, 4]\r
---\r
-import "StandardLibrary"\r
-\r
-topologicalSort :: Show a => [(a,a)] -> <Proc> [a]\r
-topologicalSort dependencies = MList.freeze answer\r
- where\r
- answer = MList.create ()\r
- \r
- -Candidate ?x, Candidate ?x => True\r
- (?x,?y) <- dependencies => Dep ?x ?y, Candidate ?x\r
- -Candidate ?x, Dep _ ?x => True\r
- Candidate ?x => MList.add answer ?x \r
- Candidate ?x, -Dep ?x ?y => Candidate ?y\r
-\r
-main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]\r
---\r
-[1, 3, 7, 2, 4]\r
+import "Prelude"
+
+gSum :: Additive a => [a] -> <Proc> a
+gSum list = getRef answer
+ where
+ answer = ref zero
+
+ constraint El a
+
+ ?x <- list => El ?x
+ -El ?x, -El ?y => El (?x + ?y)
+ El ?x => answer := ?x
+
+main = (gSum [1,6,9], gSum [1.0,6.0,9.0])
+--
+(16,16.0)
+--
+import "StandardLibrary"
+
+topologicalSort :: [(a,a)] -> <Proc> [a]
+topologicalSort dependencies = MList.freeze answer
+ where
+ answer = MList.create ()
+
+ (?x,?y) <- dependencies => Dep ?x ?y, InDegree ?x 0, InDegree ?y 1
+ -InDegree ?x ?a, -InDegree ?x ?b => InDegree ?x (?a + ?b)
+ InDegree ?x 0 => AdjustInDegrees ?x, MList.add answer ?x
+ AdjustInDegrees ?x, Dep ?x ?y => InDegree ?y (-1)
+
+main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]
+--
+[1, 3, 7, 2, 4]
+--
+import "StandardLibrary"
+
+topologicalSort :: Show a => [(a,a)] -> <Proc> [a]
+topologicalSort dependencies = MList.freeze answer
+ where
+ answer = MList.create ()
+
+ -Candidate ?x, Candidate ?x => True
+ (?x,?y) <- dependencies => Dep ?x ?y, Candidate ?x
+ -Candidate ?x, Dep _ ?x => True
+ Candidate ?x => MList.add answer ?x
+ Candidate ?x, -Dep ?x ?y => Candidate ?y
+
+main = topologicalSort [(2,4),(3,7),(7,2),(1,3)]
+--
+[1, 3, 7, 2, 4]