aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Sato <shinnya.sato@gmail.com>2021-10-19 19:23:28 +0900
committerShinya Sato <shinnya.sato@gmail.com>2021-10-19 19:23:28 +0900
commita8dbaf2c84d1b4cd73e6c8bcaf730850b53ec142 (patch)
tree29b305f5d77b0cb097cddac30372aeb36350b80a
parent56ad25efd2a36c120bbfd0458fe5c56089c15c30 (diff)
downloadinpla-a8dbaf2c84d1b4cd73e6c8bcaf730850b53ec142.tar.gz
inpla-a8dbaf2c84d1b4cd73e6c8bcaf730850b53ec142.zip
Update qsort.in
-rw-r--r--sample/qsort.in17
1 files changed, 8 insertions, 9 deletions
diff --git a/sample/qsort.in b/sample/qsort.in
index 35de8e4..1582213 100644
--- a/sample/qsort.in
+++ b/sample/qsort.in
@@ -3,17 +3,16 @@
// Rules
qsort(ret) >< [] => ret~[];
qsort(ret) >< (int x):xs =>
- part(x, left, right)~xs,
- qsort(cntl)~left, qsort(cntr)~right,
- Append(ret, x:cntl)~cntr;
+ Append(ret, x:right)~left, part(smaller, larger, x)~xs,
+ qsort(left)~smaller, qsort(right)~larger;
-// Note: `Append' is implemented as built-in.
-// Append(ret, a)~b --> ret ~ b@a
+// Note: `Append' is implemented as the following built-in agent:
+// Append(ret, b)~a --> ret ~ a@b
-part(int x, a, b) >< [] => a~[], b~[];
-part(int x, a, b) >< (int y):ys
-| y<x => b~(y:cnt), part(x, a, cnt)~ys
-| _ => a~(y:cnt), part(x, cnt, b)~ys;
+part(smaller, larger, int x) >< [] => smaller~[], larger~[];
+part(smaller, larger, int x) >< (int y):ys
+| y<x => smaller~(y:cnt), part(cnt, larger, x)~ys
+| _ => larger~(y:cnt), part(smaller, cnt, x)~ys;
// Nets