diff --git a/extra/combinators/lib/lib.factor b/extra/combinators/lib/lib.factor index 1c786a2559..44edb0ef96 100755 --- a/extra/combinators/lib/lib.factor +++ b/extra/combinators/lib/lib.factor @@ -67,6 +67,28 @@ MACRO: napply ( n -- ) : map-with2 ( obj obj list quot -- newseq ) 2 map-withn ; inline +: 2with ( param1 param2 obj quot -- obj curry ) + with with ; inline + +: 3with ( param1 param2 param3 obj quot -- obj curry ) + with with with ; inline + +: with* ( obj assoc quot -- assoc curry ) + swapd [ [ -rot ] dip call ] 2curry ; inline + +: 2with* ( obj1 obj2 assoc quot -- assoc curry ) + with* with* ; inline + +: 3with* ( obj1 obj2 obj3 assoc quot -- assoc curry ) + with* with* with* ; inline + +: assoc-each-with ( obj assoc quot -- ) + with* assoc-each ; inline + +: assoc-map-with ( obj assoc quot -- assoc ) + with* assoc-map ; inline + + MACRO: nfirst ( n -- ) [ [ swap nth ] curry [ keep ] curry ] map concat [ drop ] compose ;