From abd0e738f2c928b37acab0d5145a226dc872af69 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Thu, 28 Jul 2022 14:41:04 +0900 Subject: v0.9.1 --- Gentle_introduction_Inpla.md | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'Gentle_introduction_Inpla.md') diff --git a/Gentle_introduction_Inpla.md b/Gentle_introduction_Inpla.md index 60c1298..19ec3f1 100644 --- a/Gentle_introduction_Inpla.md +++ b/Gentle_introduction_Inpla.md @@ -252,7 +252,7 @@ Inpla has built-in agents: * `Nil`, `Cons(x,xs)`, written as `[]` and `x:xs`, respectively. * A nested `Cons` terminated with `Nil` are written as a list notation using brackets `[` and `]`. For instance, `x1 : x2: x3 : Nil` is written as `[x1,x2,x3]` . -#### Built-in rules for tuples and lists +### Built-in rules for tuples and lists There are built-in rules for the same built-in agents that each element is matched and connected such that: @@ -260,17 +260,6 @@ There are built-in rules for the same built-in agents that each element is match (x1,x2)><(y1,y2) => x1~y1, x2~y2 // This is already defined as a built-in rule. ``` -We also have a built-in agent `Append` to append two lists as shown in the following pseudo code: - -``` -Append(r, listB) ~ listA --> r ~ (listA ++ listB) // pseudo code -``` -The order `listB` and `listA` seems something strange, so a special abbreviation notation is prepared: -``` -r << Append(listA, listB) == for == Append(r, listB)~listA -``` - - * Examples of the built-in rules: ``` @@ -291,6 +280,20 @@ r << Append(listA, listB) == for == Append(r, listB)~listA >>> ``` +#### Append a list to the end of another list +We also have a built-in agent `Append` to append a list `listB` to the end of another list `listA` as shown in the following pseudo code: + +``` +Append(r, listB) ~ listA --> r ~ (listA ++ listB) // pseudo code +``` +The order `listB` and `listA` seems something strange, so a special abbreviation notation is prepared: +``` +r << Append(listA, listB) == for == Append(r, listB)~listA +``` + + + + ``` >>> Append(r, [Z, S(Z)]) ~ [A,B,C]; (4 interactions, 0.00 sec) @@ -310,6 +313,23 @@ r << Append(listA, listB) == for == Append(r, listB)~listA >>> ``` +#### `Zip`: it makes two lists into a list of pairs +A built-in agent `Zip` takes two lists and returns a list whose elements are pairs of the given two lists such as: +``` +Zip(r,[1,2,...])~[10,20,...] -->* r~[(1,10),(2,20),...]. +``` +The length of the result will be the same to the shorter one in the given lists: +``` +Zip(r,[1,2])~[10,20,30,...] -->* r~[(1,10),(2,20)]. +``` +We can write it with the abbreviation as well: +``` +>>> r << Zip([1,2,3], [10,20,30]); +(8 interactions, 0.00 sec) +>>> r; free r; +[(1,10),(2,20),(3,30)] +>>> +``` ### Eraser -- cgit v1.2.3 From 2db5c6dff3a6d4fcb8d36e3dd4768a0ecd98c06e Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Thu, 28 Jul 2022 14:47:24 +0900 Subject: v0.9.1 --- Changelog.md | 2 +- Gentle_introduction_Inpla.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Gentle_introduction_Inpla.md') diff --git a/Changelog.md b/Changelog.md index a440cbe..4e559fc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,7 @@ ### v0.9.1 (released on 28 July 2022) #### New Features -* **A built-in agent** `Zip`: it takes two lists and returns a list whose elements are pairs of the given two lists such as: +* **A built-in agent** `Zip`: It takes two lists and returns a list whose elements are pairs of the given two lists elements such as: ``` Zip(r,[1,2,...])~[10,20,...] -->* r~[(1,10),(2,20),...]. ``` diff --git a/Gentle_introduction_Inpla.md b/Gentle_introduction_Inpla.md index 19ec3f1..7ff8e34 100644 --- a/Gentle_introduction_Inpla.md +++ b/Gentle_introduction_Inpla.md @@ -313,8 +313,8 @@ r << Append(listA, listB) == for == Append(r, listB)~listA >>> ``` -#### `Zip`: it makes two lists into a list of pairs -A built-in agent `Zip` takes two lists and returns a list whose elements are pairs of the given two lists such as: +#### `Zip`: It makes two lists into a list of pairs +A built-in agent `Zip` takes two lists and returns a list whose elements are pairs of the given two lists elements such as: ``` Zip(r,[1,2,...])~[10,20,...] -->* r~[(1,10),(2,20),...]. ``` -- cgit v1.2.3 From aa938c1a2e0bae4197bb2944049b09d7e3200bc0 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Thu, 28 Jul 2022 14:55:15 +0900 Subject: v0.9.1 --- Changelog.md | 2 +- Gentle_introduction_Inpla.md | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Gentle_introduction_Inpla.md') diff --git a/Changelog.md b/Changelog.md index 4e559fc..f6cc0dc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,7 @@ ### v0.9.1 (released on 28 July 2022) #### New Features -* **A built-in agent** `Zip`: It takes two lists and returns a list whose elements are pairs of the given two lists elements such as: +* **A built-in agent** `Zip`: It takes two lists and returns a list whose elements are pairs of the given two lists elements such that: ``` Zip(r,[1,2,...])~[10,20,...] -->* r~[(1,10),(2,20),...]. ``` diff --git a/Gentle_introduction_Inpla.md b/Gentle_introduction_Inpla.md index 7ff8e34..57adee3 100644 --- a/Gentle_introduction_Inpla.md +++ b/Gentle_introduction_Inpla.md @@ -3,7 +3,11 @@ * [Nets: terms and connections](#nets-terms-and-connections) * [Interaction rules: rewriting rules for nets](#interaction-rules-rewriting-rules-for-nets) - [Example: Operations on unary natural numbers](#example-operations-on-unary-natural-numbers) + - [Abbreviation notation `<<`](#abbreviation-notation-<<) * [Built-in Agents](#built-in-agents) + - [Tuples](#tuples) + - [Lists](#lists) + - [Built-in rules for tuples and lists](#built-in-rules-for-tuples-and-lists) * [Attributes (integers)](#attributes-integers) - [Built-in anonymous agent for attributes](#built-in-anonymous-agent-for-attributes) - [Arithmetic expressions on attributes](#arithmetic-expressions-on-attributes) @@ -314,7 +318,7 @@ r << Append(listA, listB) == for == Append(r, listB)~listA ``` #### `Zip`: It makes two lists into a list of pairs -A built-in agent `Zip` takes two lists and returns a list whose elements are pairs of the given two lists elements such as: +A built-in agent `Zip` takes two lists and returns a list whose elements are pairs of the given two lists elements such that: ``` Zip(r,[1,2,...])~[10,20,...] -->* r~[(1,10),(2,20),...]. ``` -- cgit v1.2.3 From d0dcc63979c04e5c0fac4e776b87298ca3d8678a Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Thu, 28 Jul 2022 14:56:54 +0900 Subject: v0.9.1 --- Gentle_introduction_Inpla.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Gentle_introduction_Inpla.md') diff --git a/Gentle_introduction_Inpla.md b/Gentle_introduction_Inpla.md index 57adee3..0903a6f 100644 --- a/Gentle_introduction_Inpla.md +++ b/Gentle_introduction_Inpla.md @@ -3,7 +3,7 @@ * [Nets: terms and connections](#nets-terms-and-connections) * [Interaction rules: rewriting rules for nets](#interaction-rules-rewriting-rules-for-nets) - [Example: Operations on unary natural numbers](#example-operations-on-unary-natural-numbers) - - [Abbreviation notation `<<`](#abbreviation-notation-<<) + - [Abbreviation notation `<<`](#abbreviation-notation-) * [Built-in Agents](#built-in-agents) - [Tuples](#tuples) - [Lists](#lists) -- cgit v1.2.3