Example:
a = @[1, 2, 3]
I want to delete the value 3 from the sequence without using its index.
Is there a way to specify a value to delete from a sequence?
I know you can do:
a.del(2)
But this isn't what I want. Any ideas?
You would use system.find() to get the index and then del() or delete() to delete the entry. Of course find() is O(N) so it is not that fast for large seqs.
https://nim-lang.org/docs/system.html#find%2CT%2CS
Maybe use another data structure like table.
import sequtils
var a = @[1, 2, 3]
a.delete(a.find(3))
I have the feeling that finding find is hard for beginners, as it is hidden in system. How can we improve that?
I currently don't have the answer, but maybe @dom96's proposal would be the way to go?