mirror of
https://github.com/artegoser/ONLang
synced 2024-11-05 20:43:57 +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
|
||||
|
||||
- [ ] Functions
|
||||
- [x] Functions
|
||||
- [ ] imports
|
||||
- [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]}
|
||||
]
|
||||
```
|
||||
|
||||
## 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…
Reference in a new issue