From 52d8c841f18d7bac37ed6efe6eb5c41fd82312df Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 11 Jun 2009 11:03:18 -0500 Subject: [PATCH] add nover, nbi-curry, and nbi to generalizations --- basis/generalizations/generalizations.factor | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/basis/generalizations/generalizations.factor b/basis/generalizations/generalizations.factor index 28a1f7dddb..0ea179b52c 100644 --- a/basis/generalizations/generalizations.factor +++ b/basis/generalizations/generalizations.factor @@ -39,6 +39,9 @@ MACRO: firstn ( n -- ) MACRO: npick ( n -- ) 1- [ dup ] [ '[ _ dip swap ] ] repeat ; +MACRO: nover ( n -- ) + dup '[ _ 1 + npick ] n*quot ; + MACRO: ndup ( n -- ) dup '[ _ npick ] n*quot ; @@ -69,6 +72,9 @@ MACRO: ncurry ( n -- ) MACRO: nwith ( n -- ) [ with ] n*quot ; +MACRO: nbi ( n -- ) + '[ [ _ nkeep ] dip call ] ; + MACRO: ncleave ( quots n -- ) [ '[ _ '[ _ _ nkeep ] ] map [ ] join ] [ '[ _ ndrop ] ] bi compose ; @@ -91,6 +97,9 @@ MACRO: nweave ( n -- ) [ dup [ '[ _ _ mnswap ] ] with map ] keep '[ _ _ ncleave ] ; +MACRO: nbi-curry ( n -- ) + [ bi-curry ] n*quot ; + : nappend-as ( n exemplar -- seq ) [ narray concat ] dip like ; inline