# `nupp.mem.indexed` One inclusive range, checked once against every view a loop is about to index. A loop that walks two views together needs the same bounds to hold for both, and checking them separately checks them twice and says nothing about the pair. `range` takes the views and answers bounds that are valid for all of them. ```nupp local indexed = nupp.mem.indexed const bounds = indexed.range(1, 4, left, right) for i = bounds.first, bounds.last do print(left[i], right[i]) end ``` The checker validates the variadic operands against their trusted descriptors, so only a sealed view contract can be passed. The runtime body stays representation-neutral and reads the private count slot each bundled view implementation carries. See `nupp.mem.span` for the views this validates, and [ownership.md](../../../../learn/runtime/ownership/borrowing/index.html) for the borrow rules they are written against. ## Types ### `Range` _record_ ```nupp record indexed.Range readonly first: integer readonly last: integer end ``` Inclusive integer bounds validated once against every supplied indexed view. #### Fields ##### `first` ```nupp first: integer ``` The one-based first index, inclusive. ##### `last` ```nupp last: integer ``` The one-based last index, inclusive. One below `first` is an empty range. ## Functions ### `indexed.range` _function_ ```nupp function indexed.range(first: integer, last: integer, borrows ?: any): indexed.Range ``` Validates one inclusive range against every view supplied after it. At least one view is required: bounds nothing was checked against are not bounds. The views are borrowed for the call, so this may be written inline in the `for` header that uses the result. ```nupp const bounds = indexed.range(1, 4, left, right) for i = bounds.first, bounds.last do print(left[i], right[i]) end ``` #### Arguments | Name | Type | Description | | --- | --- | --- | | `first` | `integer` | the one-based first index, inclusive | | `last` | `integer` | the one-based last index, inclusive | | `borrows ...` | `any` | | #### Returns | Type | Description | | --- | --- | | `indexed.Range` | the validated bounds | #### Raises - when no view is supplied or the bounds exceed a supplied view