Skip to content

Commit

Permalink
doc: import
Browse files Browse the repository at this point in the history
  • Loading branch information
artegoser committed Aug 18, 2022
1 parent 0676d86 commit 4495ff9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TODO CONCEPTS

- [x] Functions
- [ ] imports
- [x] imports
- [x] scopes of visibility

- [ ] methods for arrays
Expand All @@ -12,7 +12,7 @@
- [ ] command execution function
- [ ] function for random
- [x] delete variable
- [ ] types conversion
- [ ] types conversion `in process`
- [ ] checking variable type
- [x] checking for the existence of a variable
- [x] create scopes without if, else, loop
Expand Down
6 changes: 6 additions & 0 deletions doc/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

`All posibilities in example.json5`

## How to import modules

```json5
[{ import: { path: "examples/assertions.onla", as: "assertions" } }]
```

## How to print

```json5
Expand Down
11 changes: 11 additions & 0 deletions examples/assertions.onla
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//artegoser
//assertions module for onlang
[
{
fn: {
name: "eq",
args: ["a", "b"],
body: [{ return: { comp: [{ var: "a" }, "==", { var: "b" }] } }],
},
},
]
File renamed without changes.
52 changes: 32 additions & 20 deletions examples/factorial.onla → examples/factorial.json5
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,54 @@
},
},

{
fn: {
name: "_eq",
args: ["a", "b"],
body: [{ return: { comp: [{ var: "a" }, "==", { var: "b" }] } }],
},
},
{ import: { path: "examples/assertions.onla", as: "assertions" } },

["10! == 3 628 800: ", { _eq: [{ fact: [10] }, 3628800] }],
["11! == 39 916 800: ", { _eq: [{ fact: [11] }, 39916800] }],
["10! == 3 628 800: ", { "assertions.eq": [{ fact: [10] }, 3628800] }],
["11! == 39 916 800: ", { "assertions.eq": [{ fact: [11] }, 39916800] }],

["12! == 479 001 600: ", { _eq: [{ fact: [12] }, 479001600] }],
["13! == 6 227 020 800: ", { _eq: [{ fact: [13] }, 6227020800] }],
["12! == 479 001 600: ", { "assertions.eq": [{ fact: [12] }, 479001600] }],
["13! == 6 227 020 800: ", { "assertions.eq": [{ fact: [13] }, 6227020800] }],

["14! == 87 178 291 200: ", { _eq: [{ fact: [14] }, 87178291200] }],
["15! == 1 307 674 368 000: ", { _eq: [{ fact: [15] }, 1307674368000] }],
[
"14! == 87 178 291 200: ",
{ "assertions.eq": [{ fact: [14] }, 87178291200] },
],
[
"15! == 1 307 674 368 000: ",
{ "assertions.eq": [{ fact: [15] }, 1307674368000] },
],

["16! == 20 922 789 888 000: ", { _eq: [{ fact: [16] }, 20922789888000] }],
["17! == 355 687 428 096 000: ", { _eq: [{ fact: [17] }, 355687428096000] }],
[
"16! == 20 922 789 888 000: ",
{ "assertions.eq": [{ fact: [16] }, 20922789888000] },
],
[
"17! == 355 687 428 096 000: ",
{ "assertions.eq": [{ fact: [17] }, 355687428096000] },
],

[
"18! == 6 402 373 705 728 000: ",
{ _eq: [{ fact: [18] }, 6402373705728000] },
{ "assertions.eq": [{ fact: [18] }, 6402373705728000] },
],
[
"19! == 121 645 100 408 832 000: ",
{ _eq: [{ fact: [19] }, 121645100408832000] },
{ "assertions.eq": [{ fact: [19] }, 121645100408832000] },
],

[
"20! == 2 432 902 008 176 640 000: ",
{ _eq: [{ fact: [20] }, 2432902008176640000] },
{ "assertions.eq": [{ fact: [20] }, 2432902008176640000] },
],
"",
["(loop) 10! == 3 628 800: ", { _eq: [{ fact_loop: [10] }, 3628800] }],
["(loop) 11! == 39 916 800: ", { _eq: [{ fact_loop: [11] }, 39916800] }],
[
"(loop) 10! == 3 628 800: ",
{ "assertions.eq": [{ fact_loop: [10] }, 3628800] },
],
[
"(loop) 11! == 39 916 800: ",
{ "assertions.eq": [{ fact_loop: [11] }, 39916800] },
],

// [
// "21! == 51 090 942 171 709 440 000: ",
Expand Down

0 comments on commit 4495ff9

Please sign in to comment.