]> gitweb.factorcode.org Git - factor.git/blob - basis/shuffle/shuffle.factor
factor: trim more using lists.
[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
4 generalizations kernel sequences sequences.generalizations ;
5 IN: shuffle
6
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
11     '[ @ _ cleave ] ;
12
13 SYNTAX: shuffle(
14     ")" parse-effect suffix! \ shuffle-effect suffix! ;
15
16 : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
17
18 : 2pick ( x y z t -- x y z t x y ) reach reach ; inline