Paste: Simplify sequences of shuffle words.
Author: | pozorvlak |
Mode: | factor |
Date: | Sun, 29 Nov 2009 19:47:09 |
Plain Text |
USING: combinators.smart kernel quotations sequences sequences.product
math.ranges assocs arrays ;
IN: tools.shuffle-simplify
: id ;
: shuffles
{
drop 2drop 3drop nip 2nip
dup 2dup 3dup dupd over 2over pick tuck
swap swapd rot -rot spin roll -roll
} ;
: shuffles-id { id } shuffles append ;
: behaviour
10 [0,b] prepend >quotation output>array ; inline
: shuffle-behaviours
shuffles-id [ [ 1quotation behaviour ] keep ] H{ } map>assoc ; inline
: simplify
>quotation behaviour shuffle-behaviours at ; inline
: simplify-all
shuffles <repetition> <product-sequence>
[ dup simplify ] H{ } map>assoc [ nip ] assoc-filter ; inline
Author: | pozorvlak |
Mode: | factor |
Date: | Sun, 29 Nov 2009 22:29:54 |
Plain Text |
USING: combinators.smart kernel quotations sequences sequences.product
math.ranges assocs arrays ;
IN: tools.shuffle-simplify
: id ;
: shuffles
{
drop 2drop 3drop nip 2nip
dup 2dup 3dup dupd over 2over pick tuck
swap swapd rot -rot spin roll -roll
} ;
: shuffles-id { id } shuffles append ;
: behaviour
10 [0,b] prepend >quotation output>array ; inline
: shuffle-behaviours
shuffles-id [ [ 1quotation behaviour ] keep ] H{ } map>assoc ; inline
: simplify
behaviour shuffle-behaviours at ; inline
: simplify-all
shuffles <repetition> <product-sequence>
[ dup simplify ] H{ } map>assoc [ nip ] assoc-filter ; inline
New Annotation