This is a type to represent lazy ranges parametrized by the container type:
type Range[V] = object
v: V
slice: Slice[int]
var r: Range[seq[int]] = Range[seq[int]](v: @[0, 10, 20, 30, 40], slice:
2..3)
# r represents the range [20, 30]
var x : r.v[0].type # ok: r.v[0].type is int, the type of the elements, so
x is an int
#If I want a generic proc to get the first element of a Range:
proc first[V](r: Range[V]): r.v[0].type = #ohhh, here r.v[0].type doesn't
work: "undeclared field v"
return r.v[r.slice.a]
echo first(r) # Would be 20
Run
Any idea to declare the "first" proc?