]> gitweb.factorcode.org Git - factor.git/commitdiff
shuffle: clean up some shuffles
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 25 Feb 2023 18:21:03 +0000 (12:21 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 26 Feb 2023 23:11:04 +0000 (17:11 -0600)
basis/shuffle/shuffle.factor
core/io/streams/sequence/sequence.factor
core/kernel/kernel.factor

index a82e11a50cdd3d10c6edd16d5ca46e83cf1ae214..5c9a62cd090b740c7cc09364e99fa847b8c94246 100644 (file)
@@ -28,3 +28,5 @@ SYNTAX: shuffle(
 : 2reach ( v w x y z -- v w x y z v w ) 5 npick 5 npick ; inline
 
 : nipdd ( w x y z -- x y z ) roll drop ; inline
+
+: spind ( w x y z -- y x w z ) [ spin ] dip ; inline
index ee46d1bcc63381ef7058acd96ce584a036729410..47faa129d378a123ecdfe7528ab90d36ab3692a9 100644 (file)
@@ -24,7 +24,7 @@ SLOT: i
     [
         [ (sequence-read-length) ]
         [ [ dup pick + ] change-i underlying>> ] bi
-    ] dip [ -roll spin dupd + copy-loop drop ] 3curry keep ; inline
+    ] dip [ 4spin dupd + copy-loop drop ] 3curry keep ; inline
 
 : (sequence-read-unsafe) ( n buf stream -- count )
     [ integer>fixnum ]
index 068fbfd7cbc416653073cc744efd702409eaf48d..9468ea6a9f16b3bbec2472b6fcf9fbfaf4c42435 100644 (file)
@@ -117,8 +117,6 @@ DEFER: if
 ! Misfits
 : tuck ( x y -- y x y ) dup -rot ; inline
 
-: spin ( x y z -- z y x ) -rot swap ; inline
-
 : rotd ( w x y z -- x y w z ) [ rot ] dip ; inline
 
 : -rotd ( w x y z -- y w x z ) [ -rot ] dip ; inline
@@ -127,6 +125,10 @@ DEFER: if
 
 : -roll ( w x y z -- z w x y ) swap -rotd ; inline
 
+: spin ( x y z -- z y x ) -rot swap ; inline
+
+: 4spin ( w x y z -- z y x w ) -roll spin ; inline
+
 : nipd ( x y z -- y z ) [ nip ] dip ; inline
 
 : overd ( x y z -- x y x z ) [ over ] dip ; inline