Skip to contents

Convenience function for the internal Slice R6 class constructor with zero-based indexing and exclusive stop index.

Usage

zb_slice(start, stop = NA, step = NA)

Arguments

start

The start index.

stop

The stop index.

step

The step size. Negative values reverse the direction of the slice, matching Python/NumPy semantics (e.g., step = -1 iterates backward from start toward stop).

Value

A Slice instance with the specified parameters.

Examples

# Equivalent to Python's arr[5:0:-1]
zb_slice(5, 0, -1)
#> <Slice>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     indices: function (length_param) 
#>     initialize: function (start, stop = NA, step = NA) 
#>     start: 5
#>     step: -1
#>     stop: 0

# Equivalent to Python's arr[-1::-1] (full reverse)
zb_slice(-1, NA, -1)
#> <Slice>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     indices: function (length_param) 
#>     initialize: function (start, stop = NA, step = NA) 
#>     start: -1
#>     step: -1
#>     stop: NA