]> gitweb.factorcode.org Git - factor.git/blob - basis/shuffle/shuffle.factor
factor: Rename MACRO: and MACRO: to have quot as the output in stack effects.
[factor.git] / basis / shuffle / shuffle.factor
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 fry
4 generalizations kernel macros make sequences
5 sequences.generalizations ;
6 IN: shuffle
7
8 MACRO: shuffle-effect ( effect -- quot )
9     [ in>> H{ } zip-index-as ] [ out>> ] bi
10     [ drop assoc-size '[ _ narray ] ]
11     [ [ of '[ _ swap nth ] ] with map ] 2bi
12     '[ @ _ cleave ] ;
13
14 SYNTAX: shuffle(
15     ")" parse-effect suffix! \ shuffle-effect suffix! ;
16
17 : tuck ( x y -- y x y ) swap over ; inline deprecated
18
19 : spin ( x y z -- z y x ) swap rot ; inline deprecated
20
21 : roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline deprecated
22
23 : -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline deprecated
24
25 : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline