From f627598905391b95d31fd81124e2b92156447b1f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 10 Jan 2008 16:55:38 -1000 Subject: [PATCH] add with* assoc-each-with --- extra/combinators/lib/lib.factor | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 ;