diff --git a/ROADMAP.md b/ROADMAP.md index d55a68e..fbfce72 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,6 +1,6 @@ # TODO CONCEPTS -- [ ] Functions +- [x] Functions - [ ] imports - [x] scopes of visibility diff --git a/doc/main.md b/doc/main.md index 0ab3c2c..e89a5b6 100644 --- a/doc/main.md +++ b/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] }], +] +```