You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The difference is that the definition from system takes 1 parameter for the index to delete whereas the definition from sequtils takes 2 parameters which represent the range of indices to delete (inclusive)
Since the range is inclusive, you would expect both results below to be the same
Example
import sequtils
var ones: seq[string]
echo"-- delete at index 50 ---"
ones =@["one"]
ones.delete(50) # unexpected: shouldn't delete anything since index 50 is out of boundsechorepr ones
ones =@["one"]
ones.delete(50,50) # unexpected: should be the same thing as delete(50)echorepr ones
Make deleting an out of bounds index return the same exact array, unmodified. (Or possibly throw an error)
Possibly make the proc return a bool if the array was modified using the discardable pragma so that its ignored by default
The documentation should say what happens for edge cases like when a parameter is out of bounds for the seq
Additional Information
$ nim -v
Nim Compiler Version 0.20.2
The text was updated successfully, but these errors were encountered:
The delete proc for seqs is defined in system and sequtils.
The difference is that the definition from system takes 1 parameter for the index to delete whereas the definition from sequtils takes 2 parameters which represent the range of indices to delete (inclusive)
Since the range is inclusive, you would expect both results below to be the same
Example
Current Output
Expected Output
Suggestions
Make deleting an out of bounds index return the same exact array, unmodified. (Or possibly throw an error)
Possibly make the proc return a bool if the array was modified using the discardable pragma so that its ignored by default
The documentation should say what happens for edge cases like when a parameter is out of bounds for the seq
Additional Information
The text was updated successfully, but these errors were encountered: