combinators.extras: adding plox by request.

db4
John Benediktsson 2013-05-14 13:44:14 -07:00
parent 832a06e848
commit a8979ad9bc
1 changed files with 10 additions and 2 deletions

View File

@ -1,7 +1,8 @@
! Copyright (C) 2013 Doug Coleman, John Benediktsson. ! Copyright (C) 2013 Doug Coleman, John Benediktsson.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays combinators fry kernel macros quotations USING: arrays combinators combinators.smart fry generalizations
sequences sequences.generalizations ; kernel macros math quotations sequences
sequences.generalizations ;
IN: combinators.extras IN: combinators.extras
: once ( quot -- ) call ; inline : once ( quot -- ) call ; inline
@ -27,3 +28,10 @@ MACRO: cleave-array ( quots -- )
: keepd ( ..a x y quot: ( ..a x y -- ..b ) -- ..b x ) : keepd ( ..a x y quot: ( ..a x y -- ..b ) -- ..b x )
2keep drop ; inline 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 ] ;