math: use "i/f" for stack effect.
parent
85784c5265
commit
141f3c9e65
|
@ -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 } "." } ;
|
||||
|
||||
|
|
|
@ -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
|
||||
] [
|
||||
|
|
Loading…
Reference in New Issue