Closed dsharlet closed 4 years ago
How about:
nda::all() or nda::slice() can also be shorthands the equivalent of ":" in Python when reading.
I decided to go ahead and use your suggestion. I already had a function interval
that was exactly your suggestion, and range
was the object that interval
produced. I basically swapped those names, and added r
to make it less verbose.
I also added all
, which is an alias for _
, which already existed.
I'm going to close this because this is C++ and I don't see any realistic and not ultra-hacky way to make this any better than short function names.
The current interval/range syntax is pretty verbose. It would be great to be able to write something like
a(x0:x1, y0:y1, z)
to crop x, y and slice z, similar to numpy style. In C++ we are more limited. The current syntax is something likea(interval(x0, x1), interval(y0, y1), z)
, ora(range<>(x0, x1 - x0), range<>(y0, y1 - y0), z)
.Possible options I can think of are:
V(begin, end)
:a(V(x0, x1), V(y0, y1), z)
. If you have an active imagination,V
is kind of like the for-all symbol...operator->
:a(x0 -> x1, y0 -> y1, z)
. It is unreasonable to require x0, y0 to be a particular type though.Some additional thoughts:
range<>
).x0 > x1
return abool_or_range
implicitly convertible type. Nor should we...