'[ dup _ >= [ 1 + ] when ] map! drop ; inline
: (>permutation) ( seq n index -- seq )
- swap [ dupd (head) <slice-unsafe> ] dip bump-indices ;
+ swap [ dupd head-to-index <slice-unsafe> ] dip bump-indices ;
: >permutation ( factoradic -- permutation )
reverse! dup [ (>permutation) ] each-index reverse! ;
[ nip ] [ nth-unsafe ] 2bi [ > ] curry find-last drop ; inline
: reverse-tail! ( n seq -- seq )
- [ swap 1 + (tail) <slice-unsafe> reverse! drop ] keep ; inline
+ [ swap 1 + index-to-tail <slice-unsafe> reverse! drop ] keep ; inline
: (next-permutation) ( seq -- seq )
dup cut-point [
over length - '[ _ + >= ] find-index drop ; inline
: increment-rest ( i seq -- )
- [ nth-unsafe ] [ swap (tail) <slice-unsafe> ] 2bi
+ [ nth-unsafe ] [ swap index-to-tail <slice-unsafe> ] 2bi
[ drop 1 + dup ] map! 2drop ; inline
: increment-last ( seq -- )
dup <zero-matrix> ; inline
<PRIVATE
-: (nth-from-end) ( n seq -- n )
+: (nth-from-tail) ( n seq -- n )
length 1 - swap - ; inline flushable
: nth-end ( n seq -- elt )
- [ (nth-from-end) ] keep nth ; inline flushable
+ [ (nth-from-tail) ] keep nth ; inline flushable
: nth-end-unsafe ( n seq -- elt )
- [ (nth-from-end) ] keep nth-unsafe ; inline flushable
+ [ (nth-from-tail) ] keep nth-unsafe ; inline flushable
: array-nth-end-unsafe ( n seq -- elt )
- [ (nth-from-end) ] keep swap 2 fixnum+fast slot ; inline flushable
+ [ (nth-from-tail) ] keep swap 2 fixnum+fast slot ; inline flushable
: set-nth-end ( elt n seq -- )
- [ (nth-from-end) ] keep set-nth ; inline
+ [ (nth-from-tail) ] keep set-nth ; inline
: set-nth-end-unsafe ( elt n seq -- )
- [ (nth-from-end) ] keep set-nth-unsafe ; inline
+ [ (nth-from-tail) ] keep set-nth-unsafe ; inline
PRIVATE>
! main-diagonal matrix
: direct-slice ( from to seq -- seq' )
check-slice direct-slice-unsafe ; inline
-: direct-head ( seq n -- seq' ) (head) direct-slice ; inline
-: direct-tail ( seq n -- seq' ) (tail) direct-slice ; inline
-: direct-head* ( seq n -- seq' ) from-end direct-head ; inline
-: direct-tail* ( seq n -- seq' ) from-end direct-tail ; inline
+: direct-head ( seq n -- seq' ) head-to-index direct-slice ; inline
+: direct-tail ( seq n -- seq' ) index-to-tail direct-slice ; inline
+: direct-head* ( seq n -- seq' ) from-tail direct-head ; inline
+: direct-tail* ( seq n -- seq' ) from-tail direct-tail ; inline
: define-array-vocab ( type -- vocab )
underlying-type
stack-checker.dependencies stack-checker.errors
stack-checker.recursive-state stack-checker.state
stack-checker.values stack-checker.visitor words ;
-FROM: sequences.private => from-end ;
IN: stack-checker.backend
: push-d ( obj -- ) meta-d push ;
[ introduce-values ] [ meta-d push-all ] bi
meta-d push-all
] when
- swap from-end [ tail ] [ update-inner-d ] bi ;
+ swap from-tail [ tail ] [ update-inner-d ] bi ;
: shorten-by ( n seq -- )
[ length swap - ] keep shorten ; inline
: (key-sched-round) ( output temp i -- output' )
key-expand-round
- [ dup 4th-from-end ] dip bitxor suffix! ; inline
+ [ dup 4th-from-tail ] dip bitxor suffix! ; inline
: (sched-interval) ( K Nr -- seq )
[ length ] dip 1 + 4 * [a..b) ; ! over the interval Nk...Nb(Nr + 1)
a2 2 seq set-nth-unsafe
a3 3 seq set-nth-unsafe ;
-: 4th-from-end ( seq -- el )
+: 4th-from-tail ( seq -- el )
[ length 4 - ] keep nth ;