Merge branch 'master' of github.com:Araq/Nimrod

This commit is contained in:
Araq 2013-01-08 22:55:00 +01:00
commit 3b52a0a9f5
3 changed files with 43 additions and 38 deletions

View file

@ -439,39 +439,39 @@ 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
* ESystem * ESystem
* EIO * EIO
* EOS * EOS
* EInvalidLibrary * EInvalidLibrary
* EResourceExhausted * EResourceExhausted
* EOutOfMemory * EOutOfMemory
* EStackOverflow * EStackOverflow
* EArithmetic * EArithmetic
* EDivByZero * EDivByZero
* EOverflow * EOverflow
* EAccessViolation * EAccessViolation
* EAssertionFailed * EAssertionFailed
* EInvalidValue * EInvalidValue
* EInvalidKey * EInvalidKey
* EInvalidIndex * EInvalidIndex
* EInvalidField * EInvalidField
* EOutOfRange * EOutOfRange
* ENoExceptionToReraise * ENoExceptionToReraise
* EInvalidObjectAssignment * EInvalidObjectAssignment
* EInvalidObjectConversion * EInvalidObjectConversion
* EFloatingPoint * EFloatingPoint
* EFloatInvalidOp * EFloatInvalidOp
* EFloatDivByZero * EFloatDivByZero
* EFloatOverflow * EFloatOverflow
* EFloatUnderflow * EFloatUnderflow
* EFloatInexact * EFloatInexact
* EDeadThread * EDeadThread
See the `system <system.html>`_ module for a description of each exception. See the `system <system.html>`_ module for a description of each exception.

View file

@ -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

View file

@ -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) for x in toSeq(countup(2, 6)):
result 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)