Apologies if this has been asked before, I am new here.
I started learning Nim yesterday, and read through the
[tutorial|[https://nim-lang.org/docs/tut1.html]](https://nim-lang.org/docs/tut1.html\]),
where it says:
> > Zero-indexed counting have two shortcuts ..< and ..^ to simplify counting
> > to one less than the higher index:
But compiling the following program with <, I get a compiler deprecation
warnings:
import tables
import strutils
proc diff_by_one(w: string, w2: string): string =
var d: int = 0
var pos: int = 0
for i, ch in w.pairs:
if ch != w2[i]:
d += 1
pos = i
if d != 1:
return ""
let a = w[0 .. <pos]
let b = w[pos+1 .. <w.len]
return join(@[a, b], "")
proc solve(words: seq[string]): string =
for i, w in words.pairs:
for u in i .. <words.len:
var w2 = words[u]
var ans = diff_by_one(w, w2)
if ans != "":
return ans
return ""
var words: seq[string]
for line in "input".lines:
words.add(line)
echo solve(words)
Run
These are the warnings:
part2.nim(13, 18) Warning: < is deprecated [Deprecated]
part2.nim(14, 22) Warning: < is deprecated [Deprecated]
part2.nim(19, 19) Warning: < is deprecated [Deprecated]
Run
Should I replace usage of < with -1? If this feature is deprecated, should we
update the tutorial?