Minor fixes
This commit is contained in:
parent
8397eac55b
commit
0ec510af11
7 changed files with 21 additions and 20 deletions
|
|
@ -24,6 +24,7 @@ block:
|
||||||
Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself.
|
Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself.
|
||||||
|
|
||||||
``` nimrod
|
``` nimrod
|
||||||
|
# This doesn't work and I don't know what it should do
|
||||||
square((
|
square((
|
||||||
var result = newSeq[float]();
|
var result = newSeq[float]();
|
||||||
for i in 0..1000:
|
for i in 0..1000:
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ The code for a simple hello world program is as follows:
|
||||||
echo "Hello World"
|
echo "Hello World"
|
||||||
```
|
```
|
||||||
|
|
||||||
To compile and execute the program, the following command should be run
|
Save this text as `helloworld.nim`. To compile and execute the program, the following command should be run
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
$ nimrod c -r --verbosity:0 ./helloworld.nim
|
$ nimrod c -r --verbosity:0 helloworld.nim
|
||||||
Hello World
|
Hello World
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ title: If, Else, While
|
||||||
|
|
||||||
# If, Else, While
|
# If, Else, While
|
||||||
|
|
||||||
Nimrod many different control flow constructs, including the standard `if`s, `else`s, and `while`s. However, Nimrod does not use an `else if` construct like many languages, it uses a more condensed `elif`.
|
Nimrod has many different control flow constructs, including the standard `if`s, `else`s, and `while`s. However, Nimrod does not use an `else if` construct like many languages, it uses a more condensed `elif`.
|
||||||
|
|
||||||
When inside a loop, `continue` can be used to skip the rest of the loop body and to begin the next iteration; `break` can be used to immediately leave the loop body.
|
When inside a loop, `continue` can be used to skip the rest of the loop body and to begin the next iteration; `break` can be used to immediately leave the loop body.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ Nimrod has several primitive types:
|
||||||
* signed integers: `int8`, `int16`, `int32`, `int64`, and `int`, where `int` is the same size as a pointer
|
* signed integers: `int8`, `int16`, `int32`, `int64`, and `int`, where `int` is the same size as a pointer
|
||||||
* unsigned integers are similar with `u` prepended to the type
|
* unsigned integers are similar with `u` prepended to the type
|
||||||
* floating points numbers: `float32`, `float64`, and `float`, where `float` is the processor's fastest type
|
* floating points numbers: `float32`, `float64`, and `float`, where `float` is the processor's fastest type
|
||||||
* characters: `char`, and basically an alias for uint8
|
* characters: `char`, which is basically an alias for uint8
|
||||||
|
|
||||||
To indicate the size of an integer literal, append `u` or `i` and the size you'd like to the end. However, this is not typically necessary.
|
To indicate the size of an integer literal, append `u` or `i` and the size you'd like to the end. However, usually this is not necessary.
|
||||||
|
|
||||||
Integers can also have `0[xX]`, `0o`, `0[Bb]` prepended to indicate a hex, octal, or binary literal, respectively. Underscores are also valid in literals, and can help with readability.
|
Integers can also have `0[xX]`, `0o`, `0[Bb]` prepended to indicate a hex, octal, or binary literal, respectively. Underscores are also valid in literals, and can help with readability.
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ let
|
||||||
c: uint8 = 256 # Compile time error
|
c: uint8 = 256 # Compile time error
|
||||||
```
|
```
|
||||||
|
|
||||||
Precedence rules are the same as most other languages, but instead of `^`, `&`, `|`, `>>`, `<<`, the `xor`, `and`, `or`, `shr`, `shl` operators are used, respectively.
|
Precedence rules are the same as in most other languages, but instead of `^`, `&`, `|`, `>>`, `<<`, the `xor`, `and`, `or`, `shr`, `shl` operators are used, respectively.
|
||||||
|
|
||||||
``` nimrod
|
``` nimrod
|
||||||
let
|
let
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ proc `**`(number, power: int): int =
|
||||||
result *= number
|
result *= number
|
||||||
```
|
```
|
||||||
|
|
||||||
A possible gotcha is declaring a variable called result and expecting it to have the same semantics.
|
A possible gotcha is declaring a new variable called `result` and expecting it to have the same semantics.
|
||||||
|
|
||||||
``` nimrod
|
``` nimrod
|
||||||
proc unexpected(): int =
|
proc unexpected(): int =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue