]> gitweb.factorcode.org Git - factor.git/blobdiff - core/effects/effects.factor
Merge branch 'master' into new_ui
[factor.git] / core / effects / effects.factor
index 77afa496cc35b88a045288cfd606e9123dd9e183..d21132aebb7b9e37c7dcb5f84f535792fba000dd 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.parser namespaces make sequences strings
 words assocs combinators accessors arrays ;
@@ -24,6 +24,7 @@ TUPLE: effect { in read-only } { out read-only } { terminated? read-only } ;
 
 GENERIC: effect>string ( obj -- str )
 M: string effect>string ;
+M: object effect>string drop "object" ;
 M: word effect>string name>> ;
 M: integer effect>string number>string ;
 M: pair effect>string first2 [ effect>string ] bi@ ": " glue ;
@@ -57,11 +58,8 @@ M: effect clone
 : split-shuffle ( stack shuffle -- stack1 stack2 )
     in>> length cut* ;
 
-: load-shuffle ( stack shuffle -- )
-    in>> [ set ] 2each ;
-
-: shuffled-values ( shuffle -- values )
-    out>> [ get ] map ;
+: shuffle-mapping ( effect -- mapping )
+    [ out>> ] [ in>> ] bi [ index ] curry map ;
 
 : shuffle ( stack shuffle -- newstack )
-    [ [ load-shuffle ] keep shuffled-values ] with-scope ;
+    shuffle-mapping swap nths ;