1 USING: accessors kernel math math.order sequences ;
2 IN: tensors.tensor-slice
5 { from integer read-only initial: 0 }
6 { to integer read-only initial: 0 }
8 { step integer read-only } ;
10 :: <step-slice> ( from to step seq -- step-slice )
11 step zero? [ "can't be zero" throw ] when
20 [ dup 0 < [ len + ] when 0 len clamp ] bi@
21 ! FIXME: make this work with steps
22 seq dup slice? [ collapse-slice ] when
25 M: step-slice virtual-exemplar seq>> ; inline
27 M: step-slice virtual@
28 [ step>> * ] [ from>> + ] [ seq>> ] tri ; inline
31 [ to>> ] [ from>> - ] [ step>> ] tri
32 dup 0 < [ [ neg 0 max ] dip neg ] when /mod
33 zero? [ 1 + ] unless ; inline
35 INSTANCE: step-slice virtual-sequence