diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 96c63cb0fe..0bc2d6f083 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -436,12 +436,12 @@ HELP: all-integers? { $notes "This word is used to implement " { $link all? } "." } ; HELP: find-integer -{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "i" { $maybe integer } } } +{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "i/f" { $maybe integer } } } { $description "Applies the quotation to each integer from 0 up to " { $snippet "n" } ", excluding " { $snippet "n" } ". Iteration stops when the quotation outputs a true value or the end is reached. If the quotation yields a true value for some integer, this word outputs that integer. Otherwise, this word outputs " { $link f } "." } { $notes "This word is used to implement " { $link find } "." } ; HELP: find-last-integer -{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "i" { $maybe integer } } } +{ $values { "n" integer } { "quot" { $quotation ( ... i -- ... ? ) } } { "i/f" { $maybe integer } } } { $description "Applies the quotation to each integer from " { $snippet "n" } " down to 0, inclusive. Iteration stops when the quotation outputs a true value or 0 is reached. If the quotation yields a true value for some integer, the word outputs that integer. Otherwise, the word outputs " { $link f } "." } { $notes "This word is used to implement " { $link find-last } "." } ; diff --git a/core/math/math.factor b/core/math/math.factor index 92d8326b5c..23f4d10a1e 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -284,13 +284,13 @@ PRIVATE> : times ( ... n quot: ( ... -- ... ) -- ... ) [ drop ] prepose each-integer ; inline -: find-integer ( ... n quot: ( ... i -- ... ? ) -- ... i ) +: find-integer ( ... n quot: ( ... i -- ... ? ) -- ... i/f ) iterate-prep (find-integer) ; inline : all-integers? ( ... n quot: ( ... i -- ... ? ) -- ... ? ) iterate-prep (all-integers?) ; inline -: find-last-integer ( ... n quot: ( ... i -- ... ? ) -- ... i ) +: find-last-integer ( ... n quot: ( ... i -- ... ? ) -- ... i/f ) over 0 < [ 2drop f ] [