2guard ( ..a x y quot: ( ..a x y -- ..b ? ) -- ..b x/f y/f )
Factor handbook » The language » Combinators » Conditional combinators

Prev:1guard ( ..a x quot: ( ..a x -- ..b ? ) -- ..b x/f )
Next:3guard ( ..a x y z quot: ( ..a x y z -- ..b ? ) -- ..b x/f y/f z/f )


Vocabulary
kernel

Inputs
xan object
yan object
quota quotation


Outputs
x/fan object
y/fan object


Word description
Calls quot on x and y and either keeps x and y or replaces them with f.

Examples
True case:
USING: kernel math prettyprint ; 3 4 [ + odd? ] 2guard [ . ] bi@
3 4

False case:
USING: kernel math prettyprint ; 3 4 [ + even? ] 2guard [ . ] bi@
f f


See also
1check, 1guard, 2check, 3check, 3guard

Definition

: 2guard
( ..a x y quot: ( ..a x y -- ..b ? ) -- ..b x/f y/f )
2check [ 2drop f f ] unless ; inline