diff --git a/basis/combinators/smart/smart.factor b/basis/combinators/smart/smart.factor index 751a1f52e1..604d2cc8e4 100644 --- a/basis/combinators/smart/smart.factor +++ b/basis/combinators/smart/smart.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors fry generalizations kernel macros math.order -stack-checker math ; +stack-checker math sequences ; IN: combinators.smart MACRO: drop-outputs ( quot -- quot' ) @@ -39,3 +39,9 @@ MACRO: append-outputs-as ( quot exemplar -- newquot ) MACRO: append-outputs ( quot -- seq ) '[ _ { } append-outputs-as ] ; + +MACRO: preserving ( quot -- ) + [ infer in>> length ] keep '[ _ ndup @ ] ; + +MACRO: smart-if ( pred true false -- ) + '[ _ preserving _ _ if ] ; inline