From a5fdbc898ee5f663e85d73ff98434fbd0df7f50b Mon Sep 17 00:00:00 2001 From: flaviut Date: Fri, 18 Jul 2014 16:15:17 -0400 Subject: [PATCH] Misc fixes --- content/arrays.md | 2 +- content/block.md | 2 +- content/case.md | 40 ++++++++++++++++++++-------------------- content/for_iterators.md | 4 ++-- content/if_else_while.md | 2 +- content/index.md | 2 +- content/primitives.md | 2 +- content/seqs.md | 4 ++-- validcodehashes.txt | 33 +++++++++++++++++++++++++++++++++ 9 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 validcodehashes.txt diff --git a/content/arrays.md b/content/arrays.md index 6481567..3c560ac 100644 --- a/content/arrays.md +++ b/content/arrays.md @@ -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" ] ``` diff --git a/content/block.md b/content/block.md index a6cbdc2..3e99fbf 100644 --- a/content/block.md +++ b/content/block.md @@ -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! diff --git a/content/case.md b/content/case.md index ca685df..f8d7a87 100644 --- a/content/case.md +++ b/content/case.md @@ -11,23 +11,23 @@ Nimrod also supports case statements, which are like switches in other languages * It is required that every possible case be covered ``` nimrod -case "charlie" -of "alfa": - echo "A" -of "bravo": - echo "B" -of "charlie": - echo "C" -else: - echo "Unrecognized letter" +case "charlie": + of "alfa": + echo "A" + of "bravo": + echo "B" + of "charlie": + echo "C" + else: + echo "Unrecognized letter" case 'h': -of 'a', 'e', 'i', 'o', 'u': - echo "Vowel" -of '\127'..'\255': - echo "Unknown" -else: - echo "Consonant" + of 'a', 'e', 'i', 'o', 'u': + echo "Vowel" + of '\127'..'\255': + echo "Unknown" + else: + echo "Consonant" proc positiveOrNegative(num: int): string = result = case num: @@ -54,11 +54,11 @@ Another feature of case statements is that the possible values are narrowed, mea ``` nimrod let x = 2 -case (x and 3) + 7 -of 7: echo "A" -of 8: echo "B" -of 9: echo "C" -of 10: echo "D" +case (x and 3) + 7: + of 7: echo "A" + of 8: echo "B" + of 9: echo "C" + of 10: echo "D" ``` ``` console $ nimrod c -r ./case_stmts_1.nim diff --git a/content/for_iterators.md b/content/for_iterators.md index 2229cca..c4eafce 100644 --- a/content/for_iterators.md +++ b/content/for_iterators.md @@ -88,7 +88,7 @@ Closure iterators hold on to their state and can be resumed at any time. The `fi ``` nimrod proc countTo(n: int): iterator(): int = - return iterator (): int = + return iterator(): int = var i = 0 while i <= n: yield i @@ -100,7 +100,7 @@ echo countTo20() var output = "" while not finished(countTo20): - output.add($countTo20()) + output.add($countTo20() & " ") echo output output = "" diff --git a/content/if_else_while.md b/content/if_else_while.md index de839e3..044f041 100644 --- a/content/if_else_while.md +++ b/content/if_else_while.md @@ -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 +``` nimrod import strutils, math randomize() diff --git a/content/index.md b/content/index.md index 0958a86..42011ca 100644 --- a/content/index.md +++ b/content/index.md @@ -10,7 +10,7 @@ title: Main Getting started? Head over to the [installation instructions](/getting_started/)! -``` nimrod +``` nimrod import tables, strutils var wordFrequencies = newCountTable[string]() diff --git a/content/primitives.md b/content/primitives.md index 58a3fda..ab9ac7f 100644 --- a/content/primitives.md +++ b/content/primitives.md @@ -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 ``` diff --git a/content/seqs.md b/content/seqs.md index 7c79931..eeb339a 100644 --- a/content/seqs.md +++ b/content/seqs.md @@ -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 ``` diff --git a/validcodehashes.txt b/validcodehashes.txt new file mode 100644 index 0000000..f61f4cf --- /dev/null +++ b/validcodehashes.txt @@ -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 \ No newline at end of file