From a8979ad9bc29aa51420d2f1791d521d781651fbd Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 14 May 2013 13:44:14 -0700 Subject: [PATCH] combinators.extras: adding plox by request. --- extra/combinators/extras/extras.factor | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/extra/combinators/extras/extras.factor b/extra/combinators/extras/extras.factor index dffd402aa1..a503891ed1 100644 --- a/extra/combinators/extras/extras.factor +++ b/extra/combinators/extras/extras.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2013 Doug Coleman, John Benediktsson. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays combinators fry kernel macros quotations -sequences sequences.generalizations ; +USING: arrays combinators combinators.smart fry generalizations +kernel macros math quotations sequences +sequences.generalizations ; IN: combinators.extras : once ( quot -- ) call ; inline @@ -27,3 +28,10 @@ MACRO: cleave-array ( quots -- ) : keepd ( ..a x y quot: ( ..a x y -- ..b ) -- ..b x ) 2keep drop ; inline + +: plox ( ... x/f quot: ( ... x -- ... ) -- ... ) + dupd when ; inline + +MACRO: smart-plox ( true -- ) + [ inputs [ 1 - [ and ] n*quot ] keep ] keep swap + '[ _ _ [ _ ndrop f ] smart-if ] ;