Merge branch 'master' of github.com:Araq/Nimrod
This commit is contained in:
commit
3b52a0a9f5
3 changed files with 43 additions and 38 deletions
|
|
@ -439,9 +439,9 @@ Exception hierarchy
|
||||||
|
|
||||||
If you want to create your own exceptions you can inherit from E_Base, but you
|
If you want to create your own exceptions you can inherit from E_Base, but you
|
||||||
can also inherit from one of the existing exceptions if they fit your purpose.
|
can also inherit from one of the existing exceptions if they fit your purpose.
|
||||||
The exception tree is:
|
The exception tree is::
|
||||||
|
|
||||||
* E_Base
|
* E_Base
|
||||||
* EAsynch
|
* EAsynch
|
||||||
* EControlC
|
* EControlC
|
||||||
* ESynch
|
* ESynch
|
||||||
|
|
|
||||||
|
|
@ -63,3 +63,9 @@ template filterIt*(seq1, pred: expr): expr {.immediate, dirty.} =
|
||||||
if pred: result.add(it)
|
if pred: result.add(it)
|
||||||
result
|
result
|
||||||
|
|
||||||
|
template toSeq*(iter: expr): expr {.immediate.} =
|
||||||
|
## Transforms any iterator into a sequence.
|
||||||
|
var result {.gensym.}: seq[type(iter)] = @[]
|
||||||
|
for x in iter: add(result, x)
|
||||||
|
result
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
discard """
|
discard """
|
||||||
output: "23456"
|
output: "2345623456"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template toSeq*(iter: expr): expr {.immediate.} =
|
import sequtils
|
||||||
var result: seq[type(iter)] = @[]
|
|
||||||
for x in iter: add(result, x)
|
|
||||||
result
|
|
||||||
|
|
||||||
|
for x in toSeq(countup(2, 6)):
|
||||||
|
stdout.write(x)
|
||||||
for x in items(toSeq(countup(2, 6))):
|
for x in items(toSeq(countup(2, 6))):
|
||||||
stdout.write(x)
|
stdout.write(x)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue