]> gitweb.factorcode.org Git - factor.git/blob - basis/shuffle/shuffle.factor
core: Add the shuffler words but without primitives.
[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 : spin ( x y z -- z y x ) swap rot ; inline deprecated
18
19 : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline