From: Doug Coleman Date: Sat, 25 Feb 2023 18:21:03 +0000 (-0600) Subject: shuffle: clean up some shuffles X-Git-Tag: 0.99~517 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=7667efb594ce815185e06944b0cfb26a9a536356 shuffle: clean up some shuffles --- diff --git a/basis/shuffle/shuffle.factor b/basis/shuffle/shuffle.factor index a82e11a50c..5c9a62cd09 100644 --- a/basis/shuffle/shuffle.factor +++ b/basis/shuffle/shuffle.factor @@ -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 diff --git a/core/io/streams/sequence/sequence.factor b/core/io/streams/sequence/sequence.factor index ee46d1bcc6..47faa129d3 100644 --- a/core/io/streams/sequence/sequence.factor +++ b/core/io/streams/sequence/sequence.factor @@ -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 ] diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 068fbfd7cb..9468ea6a9f 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -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