add sets.pop procedure (analogue to python) (#8383)
This commit is contained in:
parent
f3926b5af1
commit
8fe8bed9c3
2 changed files with 34 additions and 0 deletions
22
tests/sets/tsetpop.nim
Normal file
22
tests/sets/tsetpop.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
discard """
|
||||
targets: "c c++ js"
|
||||
output: '''1000
|
||||
0
|
||||
set is empty
|
||||
'''
|
||||
"""
|
||||
|
||||
import sets
|
||||
|
||||
var a = initSet[int]()
|
||||
for i in 1..1000:
|
||||
a.incl(i)
|
||||
echo len(a)
|
||||
for i in 1..1000:
|
||||
discard a.pop()
|
||||
echo len(a)
|
||||
|
||||
try:
|
||||
echo a.pop()
|
||||
except KeyError as e:
|
||||
echo e.msg
|
||||
Loading…
Add table
Add a link
Reference in a new issue