]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorJoe Groff <arcata@gmail.com>
Tue, 10 Feb 2009 00:46:21 +0000 (18:46 -0600)
committerJoe Groff <arcata@gmail.com>
Tue, 10 Feb 2009 00:46:21 +0000 (18:46 -0600)
1  2 
basis/shuffle/shuffle-tests.factor
basis/shuffle/shuffle.factor

index 8202146b3d8d93d9d1ed4244a7caa04bf6a29262,f8f83a9c0871db141c52c05b750cb27219e83e37..e091af2d06eed05140c14b02db1d38d48bbac411
@@@ -1,7 -1,3 +1,5 @@@
  USING: shuffle tools.test ;
  
- [ 8 ] [ 5 6 7 8 3nip ] unit-test
- [ 3 1 2 3 ] [ 1 2 3 tuckd ] unit-test
  [ 1 2 3 4 ] [ 3 4 1 2 2swap ] unit-test
 +
 +[ 4 2 3 ] [ 1 2 3 4 shuffle( a b c d -- d b c ) ] unit-test
index d375ec9c207b3c8051a8957dd6a128c984893583,10fb8b01ddb37fd8867a6ac5aa0d7a8d1779f5fe..6cae048d2764290f7ca9371725068f0fd894f95e
@@@ -1,35 -1,11 +1,29 @@@
  ! Copyright (C) 2007 Chris Double, Doug Coleman.
  ! See http://factorcode.org/license.txt for BSD license.
 -USING: kernel generalizations ;
 -
 +USING: accessors assocs combinators effects.parser generalizations
 +hashtables kernel locals locals.backend macros make math
 +parser sequences ;
  IN: shuffle
  
 +<PRIVATE
 +
 +: >index-assoc ( sequence -- assoc )
 +    dup length zip >hashtable ;
 +
 +PRIVATE>
 +
 +MACRO: shuffle-effect ( effect -- )
 +    [ out>> ] [ in>> >index-assoc ] bi
 +    [
 +        [ nip assoc-size , \ narray , ]
 +        [ [ at \ swap \ nth [ ] 3sequence ] curry map , \ cleave , ] 2bi
 +    ] [ ] make ;
 +
 +: shuffle(
 +    ")" parse-effect parsed \ shuffle-effect parsed ; parsing
 +
  : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline
  
- : nipd ( a b c -- b c ) rot drop ; inline
- : 3nip ( a b c d -- d ) 3 nnip ; inline
- : 4nip ( a b c d e -- e ) 4 nnip ; inline
  : 4dup ( a b c d -- a b c d a b c d ) 4 ndup ; inline
  
  : 4drop ( a b c d -- ) 3drop drop ; inline