1check ( ..a x quot: ( ..a x -- ..b ? ) -- ..b x ? ) (original) (raw)

Vocabulary
kernel

Inputs

x an object
quot a quotation

Outputs

x an 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

False case:

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

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

Definition

IN: kernel

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