Reorganize, fix bug in code
This commit is contained in:
parent
01c9eae713
commit
f83385dbe8
1 changed files with 8 additions and 13 deletions
|
|
@ -21,19 +21,7 @@ block:
|
||||||
let b = "3" # Probably a dumb idea
|
let b = "3" # Probably a dumb idea
|
||||||
```
|
```
|
||||||
|
|
||||||
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. An interesting and unexpected side effect of this syntax is that Nimrod is suitable even for brace purists!
|
||||||
|
|
||||||
``` nimrod
|
|
||||||
# This doesn't work and I don't know what it should do
|
|
||||||
square((
|
|
||||||
var result = newSeq[float]();
|
|
||||||
for i in 0..1000:
|
|
||||||
result[i] = i;
|
|
||||||
result
|
|
||||||
))
|
|
||||||
```
|
|
||||||
|
|
||||||
An interesting and unexpected side effect of this syntax is that Nimrod is suitable even for brace purists!
|
|
||||||
|
|
||||||
``` nimrod
|
``` nimrod
|
||||||
proc square(inSeq: seq[float]): seq[float] = (
|
proc square(inSeq: seq[float]): seq[float] = (
|
||||||
|
|
@ -42,4 +30,11 @@ proc square(inSeq: seq[float]): seq[float] = (
|
||||||
result[i] = v*v;
|
result[i] = v*v;
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
square(( # A 1001 long sequence to be squared
|
||||||
|
var result = newSeq[float]();
|
||||||
|
for i in 0..1000:
|
||||||
|
result.add(i);
|
||||||
|
result
|
||||||
|
))
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue