add smart-if to combinators.smart

db4
Doug Coleman 2009-08-19 04:38:59 -05:00
parent 507e2b7f3a
commit 2936f05ce0
1 changed files with 7 additions and 1 deletions

View File

@ -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