diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-19 20:13:22 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-19 20:13:22 +0900 |
| commit | 29bdfffbc104c326fbbe2c27564e9adfbe76872d (patch) | |
| tree | d53ded91dd9646bc2f4f4bf24a2ef4e3f282d39d /README.md | |
| parent | 9e0e17c049883d578e073b808b19063e9b0155bc (diff) | |
| download | inpla-29bdfffbc104c326fbbe2c27564e9adfbe76872d.tar.gz inpla-29bdfffbc104c326fbbe2c27564e9adfbe76872d.zip | |
Update README.md
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -126,7 +126,7 @@ $ make thread #### Insertion sort - + - Sample file: `sample/isort.in` ``` @@ -156,6 +156,42 @@ $ make thread $ ``` +#### Quick sort + + - 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$: |
