mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-22 00:41:28 +00:00
Merge branch 'master' of github.com:Araq/Nimrod
This commit is contained in:
64
doc/tut2.txt
64
doc/tut2.txt
@@ -439,39 +439,39 @@ Exception hierarchy
|
||||
|
||||
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.
|
||||
The exception tree is:
|
||||
The exception tree is::
|
||||
|
||||
* E_Base
|
||||
* EAsynch
|
||||
* EControlC
|
||||
* ESynch
|
||||
* ESystem
|
||||
* EIO
|
||||
* EOS
|
||||
* EInvalidLibrary
|
||||
* EResourceExhausted
|
||||
* EOutOfMemory
|
||||
* EStackOverflow
|
||||
* EArithmetic
|
||||
* EDivByZero
|
||||
* EOverflow
|
||||
* EAccessViolation
|
||||
* EAssertionFailed
|
||||
* EInvalidValue
|
||||
* EInvalidKey
|
||||
* EInvalidIndex
|
||||
* EInvalidField
|
||||
* EOutOfRange
|
||||
* ENoExceptionToReraise
|
||||
* EInvalidObjectAssignment
|
||||
* EInvalidObjectConversion
|
||||
* EFloatingPoint
|
||||
* EFloatInvalidOp
|
||||
* EFloatDivByZero
|
||||
* EFloatOverflow
|
||||
* EFloatUnderflow
|
||||
* EFloatInexact
|
||||
* EDeadThread
|
||||
* E_Base
|
||||
* EAsynch
|
||||
* EControlC
|
||||
* ESynch
|
||||
* ESystem
|
||||
* EIO
|
||||
* EOS
|
||||
* EInvalidLibrary
|
||||
* EResourceExhausted
|
||||
* EOutOfMemory
|
||||
* EStackOverflow
|
||||
* EArithmetic
|
||||
* EDivByZero
|
||||
* EOverflow
|
||||
* EAccessViolation
|
||||
* EAssertionFailed
|
||||
* EInvalidValue
|
||||
* EInvalidKey
|
||||
* EInvalidIndex
|
||||
* EInvalidField
|
||||
* EOutOfRange
|
||||
* ENoExceptionToReraise
|
||||
* EInvalidObjectAssignment
|
||||
* EInvalidObjectConversion
|
||||
* EFloatingPoint
|
||||
* EFloatInvalidOp
|
||||
* EFloatDivByZero
|
||||
* EFloatOverflow
|
||||
* EFloatUnderflow
|
||||
* EFloatInexact
|
||||
* EDeadThread
|
||||
|
||||
See the `system <system.html>`_ module for a description of each exception.
|
||||
|
||||
|
||||
@@ -63,3 +63,9 @@ template filterIt*(seq1, pred: expr): expr {.immediate, dirty.} =
|
||||
if pred: result.add(it)
|
||||
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 """
|
||||
output: "23456"
|
||||
output: "2345623456"
|
||||
"""
|
||||
|
||||
template toSeq*(iter: expr): expr {.immediate.} =
|
||||
var result: seq[type(iter)] = @[]
|
||||
for x in iter: add(result, x)
|
||||
result
|
||||
|
||||
import sequtils
|
||||
|
||||
for x in toSeq(countup(2, 6)):
|
||||
stdout.write(x)
|
||||
for x in items(toSeq(countup(2, 6))):
|
||||
stdout.write(x)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user