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

Prev:3if ( ..a x y z pred: ( ..a x y z -- ..b x y z ? ) true: ( ..b x y z -- ..c ) false: ( ..b x y z -- ..c ) -- ..c )
Next:2check ( ..a x y quot: ( ..a x y -- ..b ? ) -- ..b x y ? )


Vocabulary
kernel

Inputs
xan object
quota quotation


Outputs
xan object
?a boolean


Word description
Calls quot on x and keeps x under the boolean result from the quot.

Examples
True case:
USING: kernel math prettyprint ; 6 [ even? ] 1check [ . ] bi@
6 t

True case:
USING: kernel math prettyprint ; 6 [ odd? ] 1check [ . ] bi@
6 f


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

Definition

: 1check ( ..a x quot: ( ..a x -- ..b ? ) -- ..b x ? )
keep swap ; inline