]> gitweb.factorcode.org Git - factor.git/commitdiff
add ?at, simplify if-at
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 18 Aug 2008 02:27:35 +0000 (21:27 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 18 Aug 2008 02:27:35 +0000 (21:27 -0500)
extra/assocs/lib/lib.factor

index 5f4620fd64beb3a436533e41e8a8e97b50ac0c0b..2a8634987f59e62085375e53e90183b98ec380b9 100755 (executable)
@@ -38,8 +38,11 @@ IN: assocs.lib
         swap [ change-at ] 2curry assoc-each
     ] keep ; inline
 
+: ?at ( obj1 assoc -- obj1/obj2 )
+    dupd at* [ nip ] [ drop ] if ;
+
 : if-at ( obj assoc quot1 quot2 -- )
-    [ dupd at* [ not -rot ? ] keep ] 2dip if ; inline
+    [ ?at dup ] 2dip if ; inline
 
 : when-at ( obj assoc quot -- ) [ ] if-at ; inline