https://github.com/f-fathurrahman/ffr-nim-stuffs
https://github.com/f-fathurrahman/ffr-nim-stuffs
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/f-fathurrahman/ffr-nim-stuffs
- Owner: f-fathurrahman
- Created: 2017-02-17T14:21:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-24T15:03:24.000Z (almost 7 years ago)
- Last Synced: 2025-01-13T11:49:12.030Z (5 months ago)
- Language: Nim
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Learning NIM
## Building NIM
```
./build.sh
./bin/nim c koch.nim
./koch tools
./install path2install
```## Compile and run
Using `nim` command line:
```
nim compile --run filename.nim
```After executing the previous command we will obtain an executable
with the name `filename` (without `.nim` extension).## A Hello World program
```nim
echo "Hello World"
```## Variables and constants
- `var` statement declares a new local or global variable:
- `const` declares a constant. Constants are symbols which are bound to a
value. Value of a constant cannot change.- `let` statement works like `var`, but the declared symbols are single
assignment variables. After the initialization their value cannot
change.```nim
var x, y: intvar
aa, bb: int
xx, yy, zz: stringconst AA = "abc"
const input = readLine(stdin) # this will give error, constant expression expected
let input = readLine(stdin) # this will work
```## `if` statement
```nim
if a == 1
echo "a is 1"
elif a == 2
echo "a is 2"
else: # notice the colon
echo "a is not in the wanted values"
```