until-zero ( ... n quot: ( ... x -- ... y ) -- ... ) (original) (raw)

Vocabulary
math

Inputs

n a number
quot a quotation with stack effect ( ... x -- ... y )

Outputs
None

Word description
Makes a check if the number is zero, and repeatedly calls quot until the value on the stack is zero.

Examples

USING: kernel math prettyprint ; 15 [ dup . 2/ ] until-zero
15 7 3 1

See also
if-zero, when-zero, unless-zero

Definition

USING: kernel ;

IN: math

: until-zero ( ... n quot: ( ... x -- ... y ) -- ... )
[ dup zero? ] swap until drop ; inline