mirror of
https://github.com/artegoser/ONLang
synced 2025-01-07 16:43:50 +03:00
doc: add function example
This commit is contained in:
parent
b68150b304
commit
f1475c60e3
2 changed files with 27 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
# TODO CONCEPTS
|
# TODO CONCEPTS
|
||||||
|
|
||||||
- [ ] Functions
|
- [x] Functions
|
||||||
- [ ] imports
|
- [ ] imports
|
||||||
- [x] scopes of visibility
|
- [x] scopes of visibility
|
||||||
|
|
||||||
|
|
26
doc/main.md
26
doc/main.md
|
@ -188,3 +188,29 @@ works only with numbers (and variables with number type)
|
||||||
{scope:[..commands]}
|
{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] }],
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue