when-zero ( ... n quot: ( ... -- ... x ) -- ... x )
Factor handbook » The language » Numbers » Mathematical functions » Arithmetic functions

Prev:if-zero ( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b )
Next:unless-zero ( ... n quot: ( ... n -- ... ) -- ... )


Vocabulary
math

Inputs
na number
quotthe first quotation of an if-zero


Outputs
xan object


Word description
Makes an implicit check if the number is zero. A zero is dropped and the quot is called.

Examples
This word is equivalent to if-zero with an empty second quotation:
USING: math prettyprint ; 0 [ 4 ] [ ] if-zero .
4

USING: math prettyprint ; 0 [ 4 ] when-zero .
4


See also
if-zero, unless-zero, until-zero

Definition

: when-zero ( ... n quot: ( ... -- ... x ) -- ... x )
[ ] if-zero ; inline