Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Set/Nim/set-1.nim
Normal file
19
Task/Set/Nim/set-1.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var # creation
|
||||
s = {0, 3, 5, 10}
|
||||
t = {3..20, 50..55}
|
||||
|
||||
if 5 in s: echo "5 is in!" # element test
|
||||
|
||||
var
|
||||
c = s + t # union
|
||||
d = s * t # intersection
|
||||
e = s - t # difference
|
||||
|
||||
if s <= t: echo "s ⊆ t" # subset
|
||||
|
||||
if s < t: echo "s ⊂ t" # strong subset
|
||||
|
||||
if s == t: echo "s = s" # equality
|
||||
|
||||
s.incl(4) # add 4 to set
|
||||
s.excl(5) # remove 5 from set
|
||||
21
Task/Set/Nim/set-2.nim
Normal file
21
Task/Set/Nim/set-2.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import sequtils, sets
|
||||
|
||||
var # creation
|
||||
s = [0, 3, 5, 10].toHashSet
|
||||
t = toSeq(3..20).toHashSet + toSeq(50..55).toHashSet
|
||||
|
||||
if 5 in s: echo "5 is in!" # element test
|
||||
|
||||
var
|
||||
c = s + t # union
|
||||
d = s * t # intersection
|
||||
e = s - t # difference
|
||||
|
||||
if s <= t: echo "s ⊆ t" # subset
|
||||
|
||||
if s < t: echo "s ⊂ t" # strong subset
|
||||
|
||||
if s == t: echo "s = s" # equality
|
||||
|
||||
s.incl(4) # add 4 to set
|
||||
s.excl(5) # remove 5 from set
|
||||
Loading…
Add table
Add a link
Reference in a new issue