?unless ( ..a default cond: ( ..a default -- ..a new/f ) false: ( ..a default -- ..a x ) -- ..a default/x )
Factor handbook » The language » Combinators » Conditional combinators

Prev:?when ( ..a default cond: ( ..a default -- ..a new/f ) true: ( ..a new -- ..a x ) -- ..a default/x )
Next:1if ( ..a x pred: ( ..a x quot: ( ..a x -- ..b ? ) -- ..b x ? ) true: ( ..b x -- ..c ) false: ( ..b x -- ..c ) -- ..c )


Vocabulary
kernel

Inputs
defaultan object
conda quotation with stack effect ( ..a default -- ..a new/f )
falsea quotation with stack effect ( ..a default -- ..a x )


Outputs
default/xdefault or x


Word description
Calls cond on the default object and if cond outputs a new object. Otherwise, calls false with the old object.

Examples
Look up an existing word or make an error pair:
USING: arrays definitions kernel math prettyprint sequences vocabs.parser ; "+" [ search ] [ "not found" 2array ] ?unless .
+

Try to look up a word that doesn't exist:
USING: arrays definitions kernel math prettyprint sequences vocabs.parser ; "+++++" [ search ] [ "not found" 2array ] ?unless .
{ "+++++" "not found" }


See also
?if, ?when

Definition

: ?unless
( ..a default cond: ( ..a default -- ..a new/f ) false: ( ..a default -- ..a x ) -- ..a default/x )
[ ?transmute ] dip unless ; inline