Handbook
Glossary
2if ( ..a x y pred: ( ..a x y -- ..b x y ? ) true: ( ..b x y -- ..c ) false: ( ..b x y -- ..c ) -- ..c )
Factor handbook
»
The language
»
Combinators
»
Conditional combinators
Prev:
1if ( ..a x pred: ( ..a x quot: ( ..a x -- ..b ? ) -- ..b x ? ) true: ( ..b x -- ..c ) false: ( ..b x -- ..c ) -- ..c )
Next:
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 )
Vocabulary
kernel
Inputs
x
an
object
y
an
object
pred
a
quotation
true
a
quotation
false
a
quotation
Outputs
None
Word description
A variant of
if
that takes a
pred
quotation. Calls
2check
on the
pred
quotation to return a boolean and preserves
x
and
y
for the
true
or
false
branches, one of which is called.
See also
1if
,
1when
,
1unless
,
2when
,
2unless
,
3if
,
3when
,
3unless
Definition
IN:
kernel
:
2if
( ..a x y pred: ( ..a x y -- ..b x y ? ) true: ( ..b x y -- ..c ) false: ( ..b x y -- ..c ) -- ..c )
[
2check
]
2dip
if
;
inline