]> gitweb.factorcode.org Git - factor.git/commitdiff
cursors: -with- filter (e.g. foo H{ ... } [ ... ] assoc- -with- -each)
authorJoe Groff <arcata@gmail.com>
Thu, 25 Mar 2010 00:02:10 +0000 (17:02 -0700)
committerJoe Groff <arcata@gmail.com>
Thu, 25 Mar 2010 00:02:10 +0000 (17:02 -0700)
extra/cursors/cursors.factor

index 94e83398bdc746a8b98f8dd56a6902b5cd0dde5d..750540844a8085264752ca97ca603f72c8272a81 100644 (file)
@@ -517,3 +517,17 @@ MACRO: -ncontainer- ( n -- )
     swap [ ncontainer- ] dip -map-as ; inline
 : nmap ( seqs... quot n -- newseq )
     dup [ npick ] curry [ dip swap ] curry dip nmap-as ; inline
+
+!
+! utilities
+!
+
+: -with- ( invariant begin end quot -- begin end quot' )
+    [ rot ] dip '[ [ _ ] dip @ ] ; inline
+
+: -2with- ( invariant invariant begin end quot -- begin end quot' )
+    -with- -with- ; inline
+
+MACRO: -nwith- ( n -- )
+    [ -with- ] n*quot ;
+