1 USING: accessors kernel locals math math.order sequences ;
2 IN: tensors.tensor-slice
4 TUPLE: step-slice < slice { step integer read-only } ;
5 :: <step-slice> ( from to step seq -- step-slice )
6 step zero? [ "can't be zero" throw ] when
15 [ dup 0 < [ len + ] when 0 len clamp ] bi@
16 ! FIXME: make this work with steps
17 seq dup slice? [ collapse-slice ] when
20 M: step-slice virtual@
21 [ step>> * ] [ from>> + ] [ seq>> ] tri ;
24 [ to>> ] [ from>> - ] [ step>> ] tri
25 dup 0 < [ [ neg 0 max ] dip neg ] when /mod
26 zero? [ 1 + ] unless ;