unless-zero ( ... n quot: ( ... n -- ... ) -- ... )
Factor handbook > The language > Numbers > Mathematical functions > Arithmetic functions

Prev:when-zero ( ... n quot: ( ... -- ... x ) -- ... x )
Next:sgn ( x -- n )


Vocabulary
math

Inputs and outputs
na number
quotthe second quotation of an if-zero


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

Examples
This word is equivalent to if-zero with an empty first quotation:
USING: sequences math prettyprint ; 3 [ ] [ sq . ] if-zero
9

USING: sequences math prettyprint ; 3 [ sq . ] unless-zero
9


Definition


: unless-zero ( ... n quot: ( ... n -- ... ) -- ... )
[ ] swap if-zero ; inline