Misc fixes
This commit is contained in:
parent
9bebbe079b
commit
a5fdbc898e
9 changed files with 62 additions and 29 deletions
|
|
@ -30,7 +30,7 @@ Alternate methods of indexing arrays are also allowed, the first type parameter
|
|||
type
|
||||
PartsOfSpeech {.pure.} = enum
|
||||
Pronoun, Verb, Article, Adjective, Noun, Adverb
|
||||
let partOfSpeechExamples: array[PartsOfSpeech] = [
|
||||
let partOfSpeechExamples: array[PartsOfSpeech, string] = [
|
||||
"he", "reads", "the", "green", "book", "slowly"
|
||||
]
|
||||
```
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ block outer:
|
|||
|
||||
let b = 3
|
||||
block:
|
||||
let b = "3" # Probably a dumb idea
|
||||
let b = "3" # shadowing is 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. An interesting and unexpected side effect of this syntax is that Nimrod is suitable even for brace purists!
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Nimrod also supports case statements, which are like switches in other languages
|
|||
* It is required that every possible case be covered
|
||||
|
||||
``` nimrod
|
||||
case "charlie"
|
||||
case "charlie":
|
||||
of "alfa":
|
||||
echo "A"
|
||||
of "bravo":
|
||||
|
|
@ -54,7 +54,7 @@ Another feature of case statements is that the possible values are narrowed, mea
|
|||
|
||||
``` nimrod
|
||||
let x = 2
|
||||
case (x and 3) + 7
|
||||
case (x and 3) + 7:
|
||||
of 7: echo "A"
|
||||
of 8: echo "B"
|
||||
of 9: echo "C"
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ echo countTo20()
|
|||
|
||||
var output = ""
|
||||
while not finished(countTo20):
|
||||
output.add($countTo20())
|
||||
output.add($countTo20() & " ")
|
||||
echo output
|
||||
|
||||
output = ""
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ When inside a loop, `continue` can be used to skip the rest of the loop body and
|
|||
|
||||
Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops.
|
||||
|
||||
``` nimrod
|
||||
<!--skip-->``` nimrod
|
||||
import strutils, math
|
||||
|
||||
randomize()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ title: Main
|
|||
|
||||
Getting started? Head over to the [installation instructions](/getting_started/)!
|
||||
|
||||
``` nimrod
|
||||
<!--skip-->``` nimrod
|
||||
import tables, strutils
|
||||
|
||||
var wordFrequencies = newCountTable[string]()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Integers can also have `0[xX]`, `0o`, `0[Bb]` prepended to indicate a hex, octal
|
|||
``` nimrod
|
||||
let
|
||||
a: int8 = 0x7F # Works
|
||||
b: uint8 = 0x1111_1111 # Works
|
||||
b: uint8 = 0b1111_1111 # Works
|
||||
d = 0xFF # type is int
|
||||
c: uint8 = 256 # Compile time error
|
||||
```
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ title: Seqs
|
|||
|
||||
Seqs provide dynamically expandable storage, they are extended as needed.
|
||||
|
||||
There are two ways to create seqs, with the `@` operator and with the `newSeq[T](n: int)` method. Once a seq is created, it can be modified using the `add(item: T)`, `remove(idx: int)`. The length of a seq can be found through `len: int`, and the maximum index through `high: int`. The standard `items: T` and `pairs: tuple[i: int, v: T]` iterators are also available.
|
||||
There are two ways to create seqs, with the `@` operator and with the `newSeq[T](n: int)` method. Once a seq is created, it can be modified using the `add(item: T)`, `delete(idx: int)`. The length of a seq can be found through `len: int`, and the maximum index through `high: int`. The standard `items: T` and `pairs: tuple[i: int, v: T]` iterators are also available.
|
||||
|
||||
``` nimrod
|
||||
var
|
||||
|
|
@ -19,7 +19,7 @@ for i, v in a:
|
|||
for i in 4..100:
|
||||
b.add(i * i)
|
||||
|
||||
b.remove(0) # takes «O(n)» time
|
||||
b.delete(0) # takes «O(n)» time
|
||||
b = a[0] & b # Same as original b
|
||||
```
|
||||
|
||||
|
|
|
|||
33
validcodehashes.txt
Normal file
33
validcodehashes.txt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
489fd1e2356eb85f81bac48e45b186a7
|
||||
da4974745059fff2c0c3d0af688042ab
|
||||
ef380e36bcc0ebf11902cefaa10ec31b
|
||||
98f917ee2165bc9461c3e9316e8e70ee
|
||||
b243592b06e93bb3cf1f7d62a25abaa3
|
||||
1f6e436b0fbdc68e1776422df711c2bb
|
||||
394ca46d1bf22dedef7e6e753bd033c8
|
||||
8afe80a509d316a3feb3caa1c985760a
|
||||
9551565b83418876b5211869acbcf7cc
|
||||
ade4a4b3b6973bbb44f2e74aee1954f7
|
||||
26ded9e69879069fb8970403e87a24c9
|
||||
3f3dfdee017d0c329d594e9fe038ed9f
|
||||
cf09b588bb8b3c6979d24dcaff932c68
|
||||
448a6cb31706860e7957f8dcca732d85
|
||||
ac4fe7f722b390100501e638ce8a9750
|
||||
eb67590e2472e05b207856959e5461c8
|
||||
10ae94a28a0d8f23aff5afaa0367cf27
|
||||
1865b827bef365e6422beb6bc076a25d
|
||||
398863bccd3691b42500dfa143a3230b
|
||||
cdf52a33222c8402025606b0bb4da4d9
|
||||
b8875a112bc13ea83556bcf385c1160b
|
||||
30111c31170d8cd9979ae7d88fa276e7
|
||||
0e641a70cbd7b3e955bb29bde934f36e
|
||||
d599ef057eaaac83139eb8f949cef356
|
||||
e0e0e0b5724e296371d1704996096343
|
||||
2d60def87d4fa95e26b9f8eade4b0baa
|
||||
180c2775b35bd48de55453713ccb5828
|
||||
d01dfb20f1d8c1741eef320e82bfcdc2
|
||||
4f19f7a7103d8aec86dd2ab995e5a0a8
|
||||
fbb7977d27de5251fa736a627aaa8311
|
||||
847d1c4525d9056206a1e4f4855a9e10
|
||||
e4b29a303e0a22cab1f2bfb769ce66c5
|
||||
Loading…
Add table
Add a link
Reference in a new issue