2when ( ..a x y pred: ( ..a x y -- ..b ? ) true: ( ..b x y -- ..b x y ) -- ..b x y ) (original) (raw)

Vocabulary
kernel

Inputs

x an object
y an object
pred a quotation
true a quotation

Outputs

x an object
y an object

Word description
A variant of when that takes a pred quotation. Calls 2check on the pred quotation to return a boolean and preserves x and y for both branches. The true branch is called conditionally.

See also
1if, 1when, 1unless, 2if, 2unless, 3if, 3when, 3unless

Definition

IN: kernel

: 2when
( ..a x y pred: ( ..a x y -- ..b ? ) true: ( ..b x y -- ..b x y ) -- ..b x y )
[ ] 2if ; inline