}
} ;
+HELP: until-zero
+{ $values
+ { "n" number } { "quot" { $quotation ( ... x -- ... y ) } } }
+{ $description "Makes a check if the number is zero, and repeatedly calls " { $snippet "quot" } " until the value on the stack is zero." }
+{ $examples
+ { $example
+ "USING: kernel math prettyprint ;"
+ "15 [ dup . 2/ ] until-zero"
+ "15\n7\n3\n1"
+ }
+} ;
+
HELP: times
{ $values { "n" integer } { "quot" quotation } }
{ $description "Calls the quotation " { $snippet "n" } " times." }
: unless-zero ( ... n quot: ( ... n -- ... ) -- ... ) [ ] swap if-zero ; inline
+: until-zero ( ... n quot: ( ... x -- ... y ) -- ... ) [ dup zero? ] swap until drop ; inline
+
UNION: integer fixnum bignum ;
TUPLE: ratio
: sinc ( x -- y )
[ 1 ] [ pi * [ sin ] [ / ] bi ] if-zero ;
-: until-zero ( n quot -- )
- [ dup zero? ] swap until drop ; inline
-
: cum-reduce ( seq identity quot: ( prev elt -- next ) -- result cum-result )
[ dup rot ] dip dup '[ _ curry dip dupd @ ] each ; inline