Hi Chemist69,
Why I can overload [] operator for seq[T], but not for tuple? This works for
example:
proc `[]`[T](s : seq[T], keys: seq[bool]) : seq[T] =
result = newSeqOfCap[type(s[0])](s.len)
for i in 0..<s.len:
if keys[i]: result.add(s[i])
let
a = @["x1", "x2", "x3", "x4"]
b = @[true, false, false, false]
echo a[b]
As far as I can tell, nonoverloadable [] operator for tuple is oversight rather
then a need.
All other comments regarding nrow and indexing starts from zero, these
artifacts appeared when I was cutting down the code to a minimum reproducible
example. In real project everything implemented in a different more complicated
way. nrow accepts a concept and does not know the names of the tuple fields.
Tuple is not defined explicitly and is coming from user and can be different
for every query. I can't force a user to define object type for every query
they make.