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

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


Vocabulary
kernel

Inputs
xan object
quota quotation


Outputs
x/fan object


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

Examples
True case:
USING: kernel math prettyprint ; 6 [ even? ] 1guard .
6

False case:
USING: kernel math prettyprint ; 5 [ even? ] 1guard .
f


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

Definition

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