]> gitweb.factorcode.org Git - factor.git/commitdiff
basis: use head-to-index and index-to-tail
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 22 Jul 2022 22:03:04 +0000 (17:03 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 31 Jul 2022 18:24:58 +0000 (13:24 -0500)
basis/math/combinatorics/combinatorics.factor
basis/math/matrices/matrices.factor
basis/specialized-arrays/specialized-arrays.factor
basis/stack-checker/backend/backend.factor
extra/crypto/aes/aes.factor
extra/crypto/aes/utils/utils.factor

index be9cc1b9678f8bfd372cd0f1aee77db8552c13a4..0b8713cc6b055678648a431378ec0834d148cdb6 100644 (file)
@@ -48,7 +48,7 @@ PRIVATE>
     '[ 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! ;
@@ -139,7 +139,7 @@ PRIVATE>
     [ 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 [
@@ -266,7 +266,7 @@ INSTANCE: combinations immutable-sequence
     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 -- )
index c811027ec5dcf8db0e3705fef9477869adf2ab3e..847ba1e0280322795a3c927bb6660e13c31a33e5 100644 (file)
@@ -59,23 +59,23 @@ PREDICATE: zero-square-matrix < square-matrix
     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
index 88145dc90623bd99186d8ac90b566bca855cdd75..7a085d650ec058613e24480dca8681c23a18fa3b 100644 (file)
@@ -121,10 +121,10 @@ PRIVATE>
 : 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
index e3e231e93e4640517ccfb6757bf9e63cb3eb35ce..9f4342412902c0cfef147d20fa1e3379b5bd7e97 100644 (file)
@@ -5,7 +5,6 @@ math.order namespaces quotations sequences
 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 ;
@@ -36,7 +35,7 @@ IN: stack-checker.backend
         [ 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
index 48fec0c322dda43b2d880bbc1f7ba11149f3c3e0..7e63b4803e9365eaa86fa7acc9b094600a0313a9 100644 (file)
@@ -155,7 +155,7 @@ M: aes-256-key key-expand-round ( temp i -- temp' )
 
 : (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)
index 0c701ec16faf21e88f0b85e4ee0120becef703fa..9a21572d708cd1a6e92cb32759b6f2f35cad3c95 100644 (file)
@@ -57,5 +57,5 @@ IN: crypto.aes.utils
     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 ;