doc: add function example

This commit is contained in:
Artemy 2022-08-15 18:17:22 +03:00
parent b68150b304
commit f1475c60e3
2 changed files with 27 additions and 1 deletions

View file

@ -1,6 +1,6 @@
# TODO CONCEPTS
- [ ] Functions
- [x] Functions
- [ ] imports
- [x] scopes of visibility

View file

@ -188,3 +188,29 @@ works only with numbers (and variables with number type)
{scope:[..commands]}
]
```
## Create functions
```json5
[
"Creating function `sum`",
{
fn: {
name: "sum",
args: ["first", "second"],
body: [
{
return: {
calc: [{ var: "sum.first" }, "+", { var: "sum.second" }],
},
},
],
},
},
"fn sum(first, second){ return first+second};",
"Run function `sum`",
["sum(2, 2) = ", { sum: [2, 2] }],
]
```