1 ! Copyright (C) 2007 Chris Double, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs combinators effects.parser
4 generalizations kernel sequences sequences.generalizations ;
7 MACRO: shuffle-effect ( effect -- quot )
8 [ in>> H{ } zip-index-as ] [ out>> ] bi
9 [ drop assoc-size '[ _ narray ] ]
10 [ [ of '[ _ swap nth ] ] with map ] 2bi
14 ")" parse-effect suffix! \ shuffle-effect suffix! ;
16 : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
18 : 2pick ( x y z t -- x y z t x y ) reach reach ; inline
20 : 5roll ( a b c d e -- b c d e a ) [ roll ] dip swap ; inline
22 : 6roll ( a b c d e f -- b c d e f a ) [ roll ] 2dip rot ; inline
24 : 7roll ( a b c d e f g -- b c d e f g a ) [ roll ] 3dip roll ; inline
26 : 8roll ( a b c d e f g h -- b c d e f g h a ) [ roll ] 4dip 5roll ; inline
28 : 2reach ( w x y z -- w x y z w x ) reach reach ; inline
30 : nipdd ( w x y z -- x y z ) roll drop ; inline