3guard ( ..a x y z quot: ( ..a x y z -- ..b ? ) -- ..b x/f y/f z/f ) (original) (raw)

Vocabulary
kernel

Inputs

x an object
y an object
z an object
quot a quotation

Outputs

x/f an object
y/f an object
z/f an object

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

Examples
True case:

USING: kernel math prettyprint ; 3 4 5 [ + + even? ] 3guard [ . ] tri@
3 4 5

False case:

USING: kernel math prettyprint ; 3 4 5 [ + + odd? ] 3guard [ . ] tri@
f f f

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

Definition

IN: kernel

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