]> gitweb.factorcode.org Git - factor.git/commitdiff
kernel: Add withd
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 29 Jul 2022 21:30:01 +0000 (16:30 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 31 Jul 2022 18:25:41 +0000 (13:25 -0500)
10 { { 1 100 } { 2 200 } { 3 300 } } [ + + . ] withd assoc-each

Quotation sees:

10 1 100
10 2 200
10 3 300

core/kernel/kernel.factor

index 82e8553f5f48bef03b3047e6c364d314e0652914..ce9c8381cbb0d7ada0c863b44aa0fc00f547f900 100644 (file)
@@ -236,6 +236,9 @@ DEFER: if
 : 2with ( param1 param2 obj quot -- obj curried )
     with with ; inline
 
+: withd ( param obj quot -- obj curried )
+    swapd [ -rotd call ] 2curry ; inline
+
 : prepose ( quot1 quot2 -- composed )
     swap compose ; inline