summary refs log tree commit diff stats
path: root/tinyc/i386-asm.h
diff options
context:
space:
mode:
authorRokas Kupstys <rokups@zoho.com>2017-02-14 12:23:42 +0200
committerRokas Kupstys <rokups@zoho.com>2017-02-20 17:24:19 +0200
commit93149677094ffbd2ec038f3d6ec5a9aa339c8ea6 (patch)
tree5d9a1aa107ff71858d09d58ce7cebd52a4197678 /tinyc/i386-asm.h
parentc3d1b732d63b0d5e03cf194cf2c7475d344c8bc6 (diff)
downloadNim-93149677094ffbd2ec038f3d6ec5a9aa339c8ea6.tar.gz
For CI: -d:nimCoroutines
Diffstat (limited to 'tinyc/i386-asm.h')
0 files changed, 0 insertions, 0 deletions
Grzegorz Adam Hankiewicz <gradha@imap.cc> 2014-07-27 00:21:23 +0200 committer Grzegorz Adam Hankiewicz <gradha@imap.cc> 2014-07-27 00:21:23 +0200 Factors common documentation in fragment to avoid repetition.' href='/ahoang/Nim/commit/doc/sets_fragment.txt?h=devel&id=b87ec14579ac89b56be9d0b5788f3788f836245a'>b87ec1457 ^
110c4aca7 ^
b87ec1457 ^
110c4aca7 ^
b87ec1457 ^

















b87ec1457 ^







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

                                                                            



                                 
                                                              





                                                                            




                                                                             
                   
      
                       
     
              

















                                                                              







                                                                              
The set type models the mathematical notion of a set. The set's basetype can
only be an ordinal type of a certain size, namely:
  * ``int8``-``int16``
  * ``uint8``/``byte``-``uint16``
  * ``char``
  * ``enum``
or equivalent. The reason is that sets are implemented as high
performance bit vectors. Attempting to declare a set with a larger type will
result in an error:

.. code-block:: nim

  var s: set[int64] # Error: set is too large

Sets can be constructed via the set constructor: ``{}`` is the empty set. The
empty set is type compatible with any concrete set type. The constructor
can also be used to include elements (and ranges of elements):

.. code-block:: nim
  type
    CharSet = set[char]
  var
    x: CharSet
  x = {'a'..'z', '0'..'9'} # This constructs a set that contains the
                           # letters from 'a' to 'z' and the digits
                           # from '0' to '9'

These operations are supported by sets:

==================    ========================================================
operation             meaning
==================    ========================================================
``A + B``             union of two sets
``A * B``             intersection of two sets
``A - B``             difference of two sets (A without B's elements)
``A == B``            set equality
``A <= B``            subset relation (A is subset of B or equal to B)
``A < B``             strong subset relation (A is a real subset of B)
``e in A``            set membership (A contains element e)
``e notin A``         A does not contain element e
``contains(A, e)``    A contains element e
``card(A)``           the cardinality of A (number of elements in A)
``incl(A, elem)``     same as ``A = A + {elem}``
``excl(A, elem)``     same as ``A = A - {elem}``
==================    ========================================================

Sets are often used to define a type for the *flags* of a procedure. This is
a much cleaner (and type safe) solution than just defining integer
constants that should be ``or``'ed together.