]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/stack-as-data/stack-as-data.factor
stack-as-data: fix everything.
[factor.git] / extra / stack-as-data / stack-as-data.factor
index c933c51b63ba18f2003d02ad04706186262acca9..17cbc53feb8781aa56af3b96266ef0ddd91ce74c 100644 (file)
@@ -8,16 +8,16 @@ MACRO: stack-nth ( n -- quot )
     [ 1 + '[ _ nrot ] ] bi
     '[ @ @ ] ;
 
-: stack-set-nth ( obj n -- quot )
-    [ '[ drop _ ] ] dip ndip ; inline
+MACRO: stack-set-nth ( obj n -- quot )
+    '[ [ drop _ ] _ ndip ] ;
 
-: stack-exchange ( m n -- quot )
+MACRO: stack-exchange ( m n -- quot )
     [ [ stack-nth ] [ '[ _ stack-nth ] dip ] bi* ] 2keep
     swapd
-    [ stack-set-nth ] 2dip stack-set-nth ;
+    '[ _ _ stack-set-nth _ _ stack-set-nth ] ;
 
-: stack-filter ( n quot: ( obj -- ? ) -- quot' )
-    selector [ '[ _ ] replicate spread ] dip ; inline
+! MACRO: stack-filter ( n quot: ( obj -- ? ) -- quot' )
+!     selector [ '[ _ ] replicate spread ] dip ;
 
-: stack-map ( n quot: ( obj -- obj' ) -- quot' )
-    '[ _ ] replicate spread ; inline
+MACRO: stack-map ( n quot: ( obj -- obj' ) -- quot' )
+    '[ _ ] replicate '[ _ spread ] ;