system_overview.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. The System module imports several separate modules, and their documentation
  2. is in separate files:
  3. * `iterators <iterators.html>`_
  4. * `assertions <assertions.html>`_
  5. * `dollars <dollars.html>`_
  6. * `io <io.html>`_
  7. * `widestrs <widestrs.html>`_
  8. Here is a short overview of the most commonly used functions from the
  9. `system` module. Function names in the tables below are clickable and
  10. will take you to the full documentation of the function.
  11. The amount of available functions is much larger. Use the table of contents
  12. on the left-hand side and/or `Ctrl+F` to navigate through this module.
  13. Strings and characters
  14. ----------------------
  15. ============================= =======================================
  16. Proc Usage
  17. ============================= =======================================
  18. `len(s)<#len,string>`_ Return the length of a string
  19. `chr(i)<#chr,range[]>`_ Convert an `int` in the range `0..255`
  20. to a character
  21. `ord(c)<#ord,T>`_ Return `int` value of a character
  22. `a & b<#&,string,string>`_ Concatenate two strings
  23. `s.add(c)<#add,string,char>`_ Add character to the string
  24. `$<dollars.html>`_ Convert various types to string
  25. ============================= =======================================
  26. **See also:**
  27. * `strutils module <strutils.html>`_ for common string functions
  28. * `strformat module <strformat.html>`_ for string interpolation and formatting
  29. * `unicode module <unicode.html>`_ for Unicode UTF-8 handling
  30. * `strscans <strscans.html>`_ for ``scanf`` and ``scanp`` macros, which offer
  31. easier substring extraction than regular expressions
  32. * `strtabs module <strtabs.html>`_ for efficient hash tables
  33. (dictionaries, in some programming languages) mapping from strings to strings
  34. Seqs
  35. ----
  36. ======================================== ==========================================
  37. Proc Usage
  38. ======================================== ==========================================
  39. `newSeq<#newSeq>`_ Create a new sequence of a given length
  40. `newSeqOfCap<#newSeqOfCap,Natural>`_ Create a new sequence with zero length
  41. and a given capacity
  42. `setLen<#setLen,seq[T][T],Natural>`_ Set the length of a sequence
  43. `len<#len,seq[T][T]>`_ Return the length of a sequence
  44. `@<#@,array[IDX,T]>`_ Turn an array into a sequence
  45. `add<#add,seq[T][T],T>`_ Add an item to the sequence
  46. `insert<#insert,seq[T][T],T>`_ Insert an item at a specific position
  47. `delete<#delete,seq[T][T],Natural>`_ Delete an item while preserving the
  48. order of elements (`O(n)` operation)
  49. `del<#del,seq[T][T],Natural>`_ `O(1)` removal, doesn't preserve the order
  50. `pop<#pop,seq[T][T]>`_ Remove and return last item of a sequence
  51. `x & y<#&,seq[T][T],seq[T][T]>`_ Concatenate two sequences
  52. `x[a..b]<#[],openArray[T],HSlice[U,V]>`_ Slice of a sequence (both ends included)
  53. ======================================== ==========================================
  54. **See also:**
  55. * `sequtils module <sequtils.html>`_ for operations on container
  56. types (including strings)
  57. * `json module <json.html>`_ for a structure which allows heterogeneous members
  58. * `lists module <lists.html>`_ for linked lists
  59. Sets
  60. ----
  61. Built-in bit sets.
  62. =============================== ======================================
  63. Proc Usage
  64. =============================== ======================================
  65. `incl<#incl,set[T],T>`_ Include element `y` in the set `x`
  66. `excl<#excl,set[T],T>`_ Exclude element `y` from the set `x`
  67. `card<#card,set[T]>`_ Return the cardinality of the set,
  68. i.e. the number of elements
  69. `a * b<#*,set[T],set[T]>`_ Intersection
  70. `a + b<#+,set[T],set[T]>`_ Union
  71. `a - b<#-,set[T],set[T]>`_ Difference
  72. `contains<#contains,set[T],T>`_ Check if an element is in the set
  73. [a < b](#<,set[T],set[T]) Check if `a` is a subset of `b`
  74. =============================== ======================================
  75. **See also:**
  76. * `sets module <sets.html>`_ for hash sets
  77. * `intsets module <intsets.html>`_ for efficient int sets
  78. Numbers
  79. -------
  80. ============================== ================================== =====================
  81. Proc Usage Also known as
  82. (in other languages)
  83. ============================== ================================== =====================
  84. `div<#div,int,int>`_ Integer division `//`
  85. `mod<#mod,int,int>`_ Integer modulo (remainder) `%`
  86. `shl<#shl,int,SomeInteger>`_ Shift left `<<`
  87. `shr<#shr,int,SomeInteger>`_ Shift right `>>`
  88. `ashr<#ashr,int,SomeInteger>`_ Arithmetic shift right
  89. `and<#and,int,int>`_ Bitwise `and` `&`
  90. `or<#or,int,int>`_ Bitwise `or` `|`
  91. `xor<#xor,int,int>`_ Bitwise `xor` `^`
  92. `not<#not,int>`_ Bitwise `not` (complement) `~`
  93. `toInt<#toInt,float>`_ Convert floating-point number
  94. into an `int`
  95. `toFloat<#toFloat,int>`_ Convert an integer into a `float`
  96. ============================== ================================== =====================
  97. **See also:**
  98. * `math module <math.html>`_ for mathematical operations like trigonometric
  99. functions, logarithms, square and cubic roots, etc.
  100. * `complex module <complex.html>`_ for operations on complex numbers
  101. * `rationals module <rationals.html>`_ for rational numbers
  102. Ordinals
  103. --------
  104. `Ordinal type <#Ordinal>`_ includes integer, bool, character, and enumeration
  105. types, as well as their subtypes.
  106. ===================== =======================================
  107. Proc Usage
  108. ===================== =======================================
  109. `succ<#succ,T,int>`_ Successor of the value
  110. `pred<#pred,T,int>`_ Predecessor of the value
  111. `inc<#inc,T,int>`_ Increment the ordinal
  112. `dec<#dec,T,int>`_ Decrement the ordinal
  113. `high<#high,T>`_ Return the highest possible value
  114. `low<#low,T>`_ Return the lowest possible value
  115. `ord<#ord,T>`_ Return `int` value of an ordinal value
  116. ===================== =======================================
  117. Misc
  118. ----
  119. ============================================= ============================================
  120. Proc Usage
  121. ============================================= ============================================
  122. `is<#is,T,S>`_ Check if two arguments are of the same type
  123. `isnot<#isnot.t,untyped,untyped>`_ Negated version of `is`
  124. `!=<#!%3D.t,untyped,untyped>`_ Not equals
  125. `addr<#addr,T>`_ Take the address of a memory location
  126. `T and F<#and,bool,bool>`_ Boolean `and`
  127. `T or F<#or,bool,bool>`_ Boolean `or`
  128. `T xor F<#xor,bool,bool>`_ Boolean `xor` (exclusive or)
  129. `not T<#not,bool>`_ Boolean `not`
  130. `a .. b<#..,T,U>`_ Binary slice that constructs an interval
  131. `[a, b]`
  132. [a ..< b](#..<.t,untyped,untyped) Interval `[a, b)` (excluded upper bound)
  133. [runnableExamples](#runnableExamples,untyped) Create testable documentation
  134. ============================================= ============================================