aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md38
1 files changed, 37 insertions, 1 deletions
diff --git a/README.md b/README.md
index eea8b49..c7790fd 100644
--- a/README.md
+++ b/README.md
@@ -126,7 +126,7 @@ $ make thread
#### Insertion sort
-
+![insertion sort](pic/isort.png)
- Sample file: `sample/isort.in`
```
@@ -156,6 +156,42 @@ $ make thread
$
```
+#### Quick sort
+![quick sort](pic/qsort.png)
+ - Sample file: `sample/qsort.in`
+
+ ```
+ // Rules
+ qsort(ret) >< [] => ret~[];
+ qsort(ret) >< (int x):xs =>
+ Append(ret, x:right)~left, part(smaller, larger, x)~xs,
+ qsort(left)~smaller, qsort(right)~larger;
+
+ // Note: `Append' is implemented as the following built-in agent:
+ // Append(ret, b)~a --> ret ~ a@b
+
+ 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
+ isort(r)~[3,6,1,9,2];
+ r;
+ ```
+
+ - Execution:
+
+ ```
+ $ ./inpla -f sample/isort.in
+ Inpla 0.4.1 : Interaction nets as a programming language [built: 21 Sept. 2021]
+ (22 interactions, 0.00 sec)
+ [1,2,3,6,9]
+
+ $
+ ```
+
#### Other samples
- Evaluation of a lambda term `245II` in [YALE encoding](http://dl.acm.org/citation.cfm?id=289434), where `2 4 5` mean church numbers of lambda terms respectively and `I` is a lambda term $\lambda x.x$: