From: Doug Coleman Date: Wed, 27 Jul 2022 03:16:57 +0000 (-0500) Subject: Revert "core: find-last-integer -> find-last-integer-from for symmetry" X-Git-Tag: 0.99~1288 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=55925fce8eacd39ca5afca53dbc5c09d0112f087 Revert "core: find-last-integer -> find-last-integer-from for symmetry" This reverts commit 27bd3fe046ebec2624b83251be79117a2e132996. --- diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 6fb62b34e8..82f44375fb 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -454,7 +454,7 @@ HELP: find-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-from +HELP: find-last-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 548e628cc7..c4178b0f09 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -264,17 +264,6 @@ GENERIC: prev-float ( m -- n ) 3drop f ] if ; inline recursive -: find-last-integer-from ( ... n quot: ( ... i -- ... ? ) -- ... i/f ) - over 0 < [ - 2drop f - ] [ - [ call ] 2keep rot [ - drop - ] [ - [ 1 - ] dip find-last-integer-from - ] if - ] if ; inline recursive - : all-integers-from? ( ... i n quot: ( ... i -- ... ? ) -- ... ? ) 2over < [ [ nip call ] 3keep roll @@ -295,3 +284,14 @@ GENERIC: prev-float ( m -- n ) : all-integers? ( ... n quot: ( ... i -- ... ? ) -- ... ? ) [ 0 ] 2dip all-integers-from? ; inline + +: find-last-integer ( ... n quot: ( ... i -- ... ? ) -- ... i/f ) + over 0 < [ + 2drop f + ] [ + [ call ] 2keep rot [ + drop + ] [ + [ 1 - ] dip find-last-integer + ] if + ] if ; inline recursive diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 716067d7cc..cf4514ff90 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -557,7 +557,7 @@ PRIVATE> index/element ; inline : find-last-from-unsafe ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt ) - [ rot sequence-operator-last-from find-last-integer-from ] keepd + [ rot sequence-operator-last-from find-last-integer ] keepd index/element ; inline PRIVATE> diff --git a/extra/benchmark/mandel/mandel.factor b/extra/benchmark/mandel/mandel.factor index d3f72c41e8..00861f819b 100644 --- a/extra/benchmark/mandel/mandel.factor +++ b/extra/benchmark/mandel/mandel.factor @@ -14,7 +14,7 @@ IN: benchmark.mandel : c ( i j -- c ) scale center width height scale 2 / - + ; inline : count-iterations ( z max-iterations step-quot test-quot -- #iters ) - '[ drop @ dup @ ] find-last-integer-from nip ; inline + '[ drop @ dup @ ] find-last-integer nip ; inline : pixel ( c -- iterations ) [ C{ 0.0 0.0 } max-iterations ] dip diff --git a/extra/boyer-moore/boyer-moore.factor b/extra/boyer-moore/boyer-moore.factor index 34e5e90ad2..9226667425 100644 --- a/extra/boyer-moore/boyer-moore.factor +++ b/extra/boyer-moore/boyer-moore.factor @@ -46,7 +46,7 @@ TUPLE: boyer-moore pattern bad-char-table good-suffix-table ; :: mismatch? ( s1 s2 pos len -- i/f ) len 1 - [ [ pos + s1 ] keep s2 match? not ] - find-last-integer-from ; inline + find-last-integer ; inline :: (search-from) ( seq from boyer-moore -- i/f ) boyer-moore pattern>> :> pat diff --git a/extra/sequences/extras/extras.factor b/extra/sequences/extras/extras.factor index 55398ef982..81bf964762 100644 --- a/extra/sequences/extras/extras.factor +++ b/extra/sequences/extras/extras.factor @@ -646,7 +646,7 @@ PRIVATE> over [ count ] [ length ] bi* / ; inline : find-last-index ( ... seq quot: ( ... elt i -- ... ? ) -- ... i elt ) - [ [ 1 - ] dip find-last-integer-from ] (find-index) ; inline + [ [ 1 - ] dip find-last-integer ] (find-index) ; inline : map-find-last-index ( ... seq quot: ( ... elt index -- ... result/f ) -- ... result i elt ) [ find-last-index ] (map-find-index) ; inline diff --git a/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage b/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage index 08ac7e9436..b553a8c99c 100644 --- a/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage +++ b/misc/Factor.tmbundle/Syntaxes/Factor.tmLanguage @@ -187,7 +187,7 @@ match - (^|(?<=\s))(>|>=|>bignum|>fixnum|>float|>integer|<|<=|<fp-nan>|\(all-integers\?\)|\(each-integer\)|\(find-integer\)|-|/|/f|/i|/mod|2/|2^|\*|\+|\?1\+|abs|align|all-integers\?|bignum|bignum\?|bit\?|bitand|bitnot|bitor|bits>double|bits>float|bitxor|complex|complex\?|denominator|double>bits|each-integer|even\?|find-integer|find-last-integer-from|fixnum|fixnum\?|float|float>bits|float\?|fp-bitwise=|fp-infinity\?|fp-nan-payload|fp-nan\?|fp-qnan\?|fp-sign|fp-snan\?|fp-special\?|if-zero|imaginary-part|integer|integer>fixnum|integer>fixnum-strict|integer\?|log2|log2-expects-positive|log2-expects-positive\?|mod|neg|neg\?|next-float|next-power-of-2|number|number=|number\?|numerator|odd\?|power-of-2\?|prev-float|ratio|ratio\?|rational|rational\?|real|real-part|real\?|recip|rem|sgn|shift|sq|times|u>|u>=|u<|u<=|unless-zero|unordered\?|when-zero|zero\?)(\s|$) + (^|(?<=\s))(>|>=|>bignum|>fixnum|>float|>integer|<|<=|<fp-nan>|\(all-integers\?\)|\(each-integer\)|\(find-integer\)|-|/|/f|/i|/mod|2/|2^|\*|\+|\?1\+|abs|align|all-integers\?|bignum|bignum\?|bit\?|bitand|bitnot|bitor|bits>double|bits>float|bitxor|complex|complex\?|denominator|double>bits|each-integer|even\?|find-integer|find-last-integer|fixnum|fixnum\?|float|float>bits|float\?|fp-bitwise=|fp-infinity\?|fp-nan-payload|fp-nan\?|fp-qnan\?|fp-sign|fp-snan\?|fp-special\?|if-zero|imaginary-part|integer|integer>fixnum|integer>fixnum-strict|integer\?|log2|log2-expects-positive|log2-expects-positive\?|mod|neg|neg\?|next-float|next-power-of-2|number|number=|number\?|numerator|odd\?|power-of-2\?|prev-float|ratio|ratio\?|rational|rational\?|real|real-part|real\?|recip|rem|sgn|shift|sq|times|u>|u>=|u<|u<=|unless-zero|unordered\?|when-zero|zero\?)(\s|$) name keyword.control.math.factor diff --git a/misc/atom/grammars/factor.cson b/misc/atom/grammars/factor.cson index 7d8b186545..2673abb4a7 100644 --- a/misc/atom/grammars/factor.cson +++ b/misc/atom/grammars/factor.cson @@ -89,7 +89,7 @@ patterns: [ name: "keyword.control.combinators.factor" } { - match: "(^|(?<=\\s))(>|>=|>bignum|>fixnum|>float|>integer|<|<=||\\(all-integers\\?\\)|\\(each-integer\\)|\\(find-integer\\)|-|/|/f|/i|/mod|2/|2^|\\*|\\+|\\?1\\+|abs|align|all-integers\\?|bignum|bignum\\?|bit\\?|bitand|bitnot|bitor|bits>double|bits>float|bitxor|complex|complex\\?|denominator|double>bits|each-integer|even\\?|find-integer|find-last-integer-from|fixnum|fixnum\\?|float|float>bits|float\\?|fp-bitwise=|fp-infinity\\?|fp-nan-payload|fp-nan\\?|fp-qnan\\?|fp-sign|fp-snan\\?|fp-special\\?|if-zero|imaginary-part|integer|integer>fixnum|integer>fixnum-strict|integer\\?|log2|log2-expects-positive|log2-expects-positive\\?|mod|neg|neg\\?|next-float|next-power-of-2|number|number=|number\\?|numerator|odd\\?|power-of-2\\?|prev-float|ratio|ratio\\?|rational|rational\\?|real|real-part|real\\?|recip|rem|sgn|shift|sq|times|u>|u>=|u<|u<=|unless-zero|unordered\\?|when-zero|zero\\?)(\\s|$)" + match: "(^|(?<=\\s))(>|>=|>bignum|>fixnum|>float|>integer|<|<=||\\(all-integers\\?\\)|\\(each-integer\\)|\\(find-integer\\)|-|/|/f|/i|/mod|2/|2^|\\*|\\+|\\?1\\+|abs|align|all-integers\\?|bignum|bignum\\?|bit\\?|bitand|bitnot|bitor|bits>double|bits>float|bitxor|complex|complex\\?|denominator|double>bits|each-integer|even\\?|find-integer|find-last-integer|fixnum|fixnum\\?|float|float>bits|float\\?|fp-bitwise=|fp-infinity\\?|fp-nan-payload|fp-nan\\?|fp-qnan\\?|fp-sign|fp-snan\\?|fp-special\\?|if-zero|imaginary-part|integer|integer>fixnum|integer>fixnum-strict|integer\\?|log2|log2-expects-positive|log2-expects-positive\\?|mod|neg|neg\\?|next-float|next-power-of-2|number|number=|number\\?|numerator|odd\\?|power-of-2\\?|prev-float|ratio|ratio\\?|rational|rational\\?|real|real-part|real\\?|recip|rem|sgn|shift|sq|times|u>|u>=|u<|u<=|unless-zero|unordered\\?|when-zero|zero\\?)(\\s|$)" name: "keyword.control.math.factor" } { diff --git a/misc/vim/syntax/factor/generated.vim b/misc/vim/syntax/factor/generated.vim index 4a8176766a..d648dc183f 100644 --- a/misc/vim/syntax/factor/generated.vim +++ b/misc/vim/syntax/factor/generated.vim @@ -37,7 +37,7 @@ SynKeywordFactorWord factorWord_io_files | syn keyword factorWord_io_files conta SynKeywordFactorWord factorWord_kernel | syn keyword factorWord_kernel contained (clone) -roll -rot -rotd 2bi 2bi* 2bi@ 2curry 2dip 2drop 2dup 2keep 2keepd 2nip 2nipd 2over 2tri 2tri* 2tri@ 2with 3bi 3curry 3dip 3drop 3dup 3keep 3nip 3nipd 3tri 4dip 4drop 4dup 4keep 4nip 5drop 5nip = >boolean ? ?if and assert assert= assert? bi bi* bi-curry bi-curry* bi-curry@ bi@ boa boolean boolean? both? build call callstack callstack>array callstack? clear clone compose composed composed? curried curried? curry die dip do drop dup dupd either? eq? equal? execute get-callstack get-datastack get-retainstack hashcode hashcode* identity-hashcode identity-tuple identity-tuple? if if* keep keepd keepdd loop most new nip nipd not null object or over overd pick pickd prepose reach recursive-hashcode roll rot rotd same? spin swap swapd throw tri tri* tri-curry tri-curry* tri-curry@ tri@ tuck tuple tuple? unless unless* until when when* while while* with wrapper wrapper? xor SynKeywordFactorWord factorWord_layouts | syn keyword factorWord_layouts contained (first-bignum) (fixnum-bits) (max-array-capacity) 32-bit? 64-bit? bootstrap-cell bootstrap-cell-bits bootstrap-cells bootstrap-first-bignum bootstrap-fixnum-bits bootstrap-max-array-capacity bootstrap-most-negative-fixnum bootstrap-most-positive-fixnum cell cell-bits cells data-alignment first-bignum fixnum-bits hashcode-shift header-bits immediate immediate? leaf-stack-frame-size max-array-capacity mega-cache-size most-negative-fixnum most-positive-fixnum num-types tag-bits tag-fixnum tag-header tag-mask type-number type-numbers untag-fixnum SynKeywordFactorWord factorWord_make | syn keyword factorWord_make contained % %% , ,+ ,, building make -SynKeywordFactorWord factorWord_math | syn keyword factorWord_math contained (all-integers?) (each-integer) (find-integer) * + - / /f /i /mod 2/ 2^ < <= > >= >bignum >fixnum >float >fraction >integer >rect ?1+ abs align all-integers? bignum bignum? bit? bitand bitnot bitor bits>double bits>float bitxor complex complex? denominator double>bits each-integer even? find-integer find-last-integer-from fixnum fixnum? float float>bits float? fp-bitwise= fp-infinity? fp-nan-payload fp-nan? fp-qnan? fp-sign fp-snan? fp-special? gcd if-zero imaginary-part integer integer>fixnum integer>fixnum-strict integer? log2 log2-expects-positive log2-expects-positive? mod neg neg? next-float next-power-of-2 number number= number? numerator odd? power-of-2? prev-float ratio ratio? rational rational? real real-part real? recip rect> rem sgn shift simple-gcd sq times u< u<= u> u>= unless-zero unordered? until-zero when-zero zero? +SynKeywordFactorWord factorWord_math | syn keyword factorWord_math contained (all-integers?) (each-integer) (find-integer) * + - / /f /i /mod 2/ 2^ < <= > >= >bignum >fixnum >float >fraction >integer >rect ?1+ abs align all-integers? bignum bignum? bit? bitand bitnot bitor bits>double bits>float bitxor complex complex? denominator double>bits each-integer even? find-integer find-last-integer fixnum fixnum? float float>bits float? fp-bitwise= fp-infinity? fp-nan-payload fp-nan? fp-qnan? fp-sign fp-snan? fp-special? gcd if-zero imaginary-part integer integer>fixnum integer>fixnum-strict integer? log2 log2-expects-positive log2-expects-positive? mod neg neg? next-float next-power-of-2 number number= number? numerator odd? power-of-2? prev-float ratio ratio? rational rational? real real-part real? recip rect> rem sgn shift simple-gcd sq times u< u<= u> u>= unless-zero unordered? until-zero when-zero zero? SynKeywordFactorWord factorWord_math_order | syn keyword factorWord_math_order contained +eq+ +gt+ +lt+ <=> >=< [-] after=? after? before=? before? between? clamp compare invert-comparison max min SynKeywordFactorWord factorWord_memory | syn keyword factorWord_memory contained all-instances compact-gc gc instances minor-gc save save-image save-image-and-exit saving-path size SynKeywordFactorWord factorWord_namespaces | syn keyword factorWord_namespaces contained +@ change change-global counter dec get get-global get-namestack global inc init-namestack initialize namespace off on set set-global set-namestack toggle with-global with-scope with-variable with-variable-off with-variable-on with-variables