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 generalizations
4 hashtables kernel locals locals.backend macros make math
10 : >index-assoc ( sequence -- assoc )
11 dup length zip >hashtable ;
15 MACRO: shuffle-effect ( effect -- )
16 [ out>> ] [ in>> >index-assoc ] bi
18 [ nip assoc-size , \ narray , ]
19 [ [ at \ swap \ nth [ ] 3sequence ] curry map , \ cleave , ] 2bi
23 ")" parse-effect parsed \ shuffle-effect parsed ; parsing
25 : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
27 : nipd ( a b c -- b c ) rot drop ; inline
29 : 3nip ( a b c d -- d ) 3 nnip ; inline
31 : 4nip ( a b c d e -- e ) 4 nnip ; inline
33 : 4dup ( a b c d -- a b c d a b c d ) 4 ndup ; inline
35 : 4drop ( a b c d -- ) 3drop drop ; inline
37 : tuckd ( x y z -- z x y z ) 2 ntuck ; inline