forked from ground/ground
More reliable scoping
This commit is contained in:
0
docs/writing-a-program
Normal file
0
docs/writing-a-program
Normal file
25
docs/writing-a-program.md
Normal file
25
docs/writing-a-program.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## Writing programs with Ground
|
||||
|
||||
Ground is a very easy language to learn. In this guide, you will learn how to write a simple calculator in Ground, as well as best practices (which there aren't many of, since Ground is so simple).
|
||||
|
||||
Note: This assumes you've read and understand the syntax.md document in this folder.
|
||||
|
||||
### Let's start!
|
||||
|
||||
Open a new file with the `.grnd` extension. Should look something like this:
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
(Real empty in that file.)
|
||||
|
||||
Let's add some code! Create a label for the start, since we'll loop back once we've calculated, and ask for the user's input:
|
||||
|
||||
```
|
||||
@start
|
||||
stdout "Calculation: "
|
||||
stdin &calc
|
||||
```
|
||||
|
||||
At the calc variable, we have whatever the user typed in. This should look something like `9+10`, `1 / 3` or who knows what else. But first we should organise this data. Let's create a loop to iterate through this input, and a counter to keep moving forward:
|
Reference in New Issue
Block a user