From 29bdfffbc104c326fbbe2c27564e9adfbe76872d Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Tue, 19 Oct 2021 20:13:22 +0900 Subject: Update README.md --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'README.md') 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 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$: -- cgit v1.2.3