Ok, it's only been a few days of me learning nim, so this may as well be one of
the basic things but, Idk. So my problem is that when I make a sequence and
pass it's shallow copy to a data type and add to it, only the sequence inside
the data type gets added to. To better illustrate this, here's a piece of code
type
lis = ref object of RootObj
v : seq[int]
let s = @[1, 2, 3, 4, 5]
let list = lis()
shallowCopy(list.v, s)
list.v.add(6)
echo list.v
echo s
Run
and it outputs
@[1, 2, 3, 4, 5, 6]
@[1, 2, 3, 4, 5]
Run
but I expected it to output this
@[1, 2, 3, 4, 5, 6]
@[1, 2, 3, 4, 5, 6]
Run
Now, if this can't be done with sequences, can you please point me to a data
structure that allows push, pop, and insertion where this can be done. Thanks
in advance.