2008-07-08 13:34:52 -04:00
|
|
|
! Copyright (C) 2007 Chris Double, Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2015-07-09 17:45:41 -04:00
|
|
|
USING: accessors assocs combinators effects.parser fry
|
|
|
|
generalizations kernel macros make sequences
|
|
|
|
sequences.generalizations ;
|
2008-07-08 13:34:52 -04:00
|
|
|
IN: shuffle
|
|
|
|
|
2015-07-19 01:16:11 -04:00
|
|
|
MACRO: shuffle-effect ( effect -- quot )
|
2015-07-09 17:45:41 -04:00
|
|
|
[ in>> H{ } zip-index-as ] [ out>> ] bi
|
|
|
|
[ drop assoc-size '[ _ narray ] ]
|
|
|
|
[ [ of '[ _ swap nth ] ] with map ] 2bi
|
|
|
|
'[ @ _ cleave ] ;
|
2009-02-09 12:40:05 -05:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: shuffle(
|
2009-10-28 14:38:27 -04:00
|
|
|
")" parse-effect suffix! \ shuffle-effect suffix! ;
|
2009-02-09 12:40:05 -05:00
|
|
|
|
2009-11-05 23:47:05 -05:00
|
|
|
: tuck ( x y -- y x y ) swap over ; inline deprecated
|
|
|
|
|
2009-11-05 16:40:48 -05:00
|
|
|
: spin ( x y z -- z y x ) swap rot ; inline deprecated
|
|
|
|
|
2009-10-30 18:11:45 -04:00
|
|
|
: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline deprecated
|
|
|
|
|
|
|
|
: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline deprecated
|
|
|
|
|
2008-12-03 09:46:16 -05:00
|
|
|
: 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
|