let
pt1x = 12
pt1y = 3
pt2x = 11
pt2y = 2
pt3x = 10
pt3y = 2
var threads = newSeq[seq[int]](1)
threads[0].newSeq(2)
threads.add(@[pt1x, pt1y])
threads.add(@[pt2x, pt2y])
threads.add(@[pt3x, pt3y])
echo threads # @[@[0, 0], @[12, 3], @[11, 2], @[10, 2]]
# keeping the rest of the code the same
# removing the int from newSeq call produces runtime error
var threads = newSeq[seq[int]]()
Traceback (most recent call last)
threads.nim(11) threads
Error: unhandled exception: index out of bounds [EInvalidIndex]
What is your problem here? If you don't want threads[0], don't newSeq(1)!
var threads = newSeq[seq[int]](0)
threads.add(@[pt1x, pt1y])
threads.add(@[pt2x, pt2y])
threads.add(@[pt3x, pt3y])
Also possible:
var threads = @[
@[pt1x, pt1y],
@[pt2x, pt2y],
@[pt3x, pt3y]]