]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: rename supremum-by/infinum-by
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 23 Oct 2023 17:47:41 +0000 (10:47 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 23 Oct 2023 17:47:41 +0000 (10:47 -0700)
basis/math/statistics/statistics.factor
core/sequences/sequences-docs.factor
core/sequences/sequences-tests.factor
core/sequences/sequences.factor
extra/io/streams/ansi/ansi.factor
extra/math/binpack/binpack.factor
extra/project-euler/066/066.factor
extra/rosetta-code/multisplit/multisplit.factor

index a8a2d9583bb132b88cb346072f588b1f0235c5cb..6c2992800cc4411390a55a3705af7a3f7a8f1807 100644 (file)
@@ -18,7 +18,7 @@ IN: math.statistics
     0 mean-ddof ; inline
 
 : meanest ( seq -- x )
-    [ mean ] keep [ - abs ] with infimum-by ;
+    [ mean ] keep [ - abs ] with minimum-by ;
 
 GENERIC: sum-of-squares ( seq -- x )
 M: object sum-of-squares [ sq ] map-sum ;
@@ -273,7 +273,7 @@ PRIVATE>
     dup recip <array> ; inline
 
 : mode ( seq -- x )
-    histogram >alist [ second ] supremum-by first ;
+    histogram >alist [ second ] maximum-by first ;
 
 : minmax ( seq -- min max )
     [ first dup ] keep [ [ min ] [ max ] bi-curry bi* ] 1 each-from ;
index 4a210709f21ef8227222bcfaf9d49e744617e611..540296e2242dbb1b20af11c097007cebcc34db6c 100644 (file)
@@ -1462,7 +1462,7 @@ HELP: minimum
 }
 { $errors "Throws an error if the sequence is empty." } ;
 
-HELP: infimum-by
+HELP: minimum-by
 { $values
     { "seq" sequence } { "quot" quotation }
     { "elt" object }
@@ -1471,7 +1471,7 @@ HELP: infimum-by
 { $examples
     "Example:"
     { $example "USING: sequences prettyprint ;"
-        "{ { 1 2 } { 1 2 3 } { 1 2 3 4 } } [ length ] infimum-by ."
+        "{ { 1 2 } { 1 2 3 } { 1 2 3 4 } } [ length ] minimum-by ."
         "{ 1 2 }"
     }
 }
@@ -1494,7 +1494,7 @@ HELP: maximum
 }
 { $errors "Throws an error if the sequence is empty." } ;
 
-HELP: supremum-by
+HELP: maximum-by
 { $values
     { "seq" sequence } { "quot" quotation }
     { "elt" object }
@@ -1503,13 +1503,13 @@ HELP: supremum-by
 { $examples
     "Example:"
     { $example "USING: sequences prettyprint ;"
-        "{ { 1 2 } { 1 2 3 } { 1 2 3 4 } } [ length ] supremum-by ."
+        "{ { 1 2 } { 1 2 3 } { 1 2 3 4 } } [ length ] maximum-by ."
         "{ 1 2 3 4 }"
     }
 }
 { $errors "Throws an error if the sequence is empty." } ;
 
-{ min max minimum infimum-by maximum supremum-by } related-words
+{ min max minimum minimum-by maximum maximum-by } related-words
 
 HELP: shortest
 { $values { "seqs" sequence } { "elt" object } }
@@ -2168,9 +2168,9 @@ ARTICLE: "sequences-combinators" "Sequence combinators"
 "Superlatives with " { $link min } " and " { $link max } ":"
 { $subsections
     minimum
-    infimum-by
+    minimum-by
     maximum
-    supremum-by
+    maximum-by
     shorter
     longer
     shorter?
index 8b224f37cc199f9e2f8dab68eab446232faf6c52..500feeb3ddd3b1051521525a47cc1fa1daee8718 100644 (file)
@@ -393,14 +393,14 @@ M: bogus-hashcode hashcode* 2drop 0 >bignum ;
 { 4 } [ 5 <iota> maximum ] unit-test
 { 0 } [ 5 <iota> minimum ] unit-test
 
-{ 4 } [ 5 <iota> [ ] supremum-by ] unit-test
-{ 0 } [ 5 <iota> [ ] infimum-by ] unit-test
-{ "bar" } [ { "bar" "baz" "qux" } [ length ] supremum-by ] unit-test
-{ "bar" } [ { "bar" "baz" "qux" } [ length ] infimum-by ] unit-test
-{ { "foo" } } [ { { "foo" } { "bar" } } [ first ] supremum-by ] unit-test
-{ { "bar" } } [ { { "foo" } { "bar" } } [ first ] infimum-by ] unit-test
-{ -2 1 } [ -2 { 1 2 3 } [ over ^ ] supremum-by ] unit-test
-{ -2 3 } [ -2 { 1 2 3 } [ over ^ ] infimum-by ] unit-test
+{ 4 } [ 5 <iota> [ ] maximum-by ] unit-test
+{ 0 } [ 5 <iota> [ ] minimum-by ] unit-test
+{ "bar" } [ { "bar" "baz" "qux" } [ length ] maximum-by ] unit-test
+{ "bar" } [ { "bar" "baz" "qux" } [ length ] minimum-by ] unit-test
+{ { "foo" } } [ { { "foo" } { "bar" } } [ first ] maximum-by ] unit-test
+{ { "bar" } } [ { { "foo" } { "bar" } } [ first ] minimum-by ] unit-test
+{ -2 1 } [ -2 { 1 2 3 } [ over ^ ] maximum-by ] unit-test
+{ -2 3 } [ -2 { 1 2 3 } [ over ^ ] minimum-by ] unit-test
 
 { { 0 0 255 } } [
     {
@@ -415,7 +415,7 @@ M: bogus-hashcode hashcode* 2drop 0 >bignum ;
         { 0 255 215 }
         { 135 0 95 }
         { 255 0 175 }
-    } [ { 0 0 255 } distance ] infimum-by
+    } [ { 0 0 255 } distance ] minimum-by
 ] unit-test
 
 [ -1 0 <repetition> ] must-fail
index 52200979eea43d0711bb8b6948a77a685a51ba5b..b4af2c55f130537f6b5a24dc35729a0749aa67f1 100644 (file)
@@ -1190,15 +1190,18 @@ ALIAS: supremum maximum deprecated
 
 PRIVATE>
 
-: supremum-by ( ... seq quot: ( ... elt -- ... x ) -- ... elt )
+: maximum-by ( ... seq quot: ( ... elt -- ... x ) -- ... elt )
     [ after? ] select-by ; inline
 
-: infimum-by ( ... seq quot: ( ... elt -- ... x ) -- ... elt )
+: minimum-by ( ... seq quot: ( ... elt -- ... x ) -- ... elt )
     [ before? ] select-by ; inline
 
-: shortest ( seqs -- elt ) [ length ] infimum-by ;
+ALIAS: supremum-by maximum-by deprecated
+ALIAS: infimum-by minimum-by deprecated
 
-: longest ( seqs -- elt ) [ length ] supremum-by ;
+: shortest ( seqs -- elt ) [ length ] minimum-by ;
+
+: longest ( seqs -- elt ) [ length ] maximum-by ;
 
 ! We hand-optimize flip to such a degree because type hints
 ! cannot express that an array is an array of arrays yet, and
index 32b2f5f6c01442714f82b7ee25de6e968e13874f..03c6d426bf8dc282c5518b504fb84ff767df10a5 100644 (file)
@@ -38,7 +38,7 @@ CONSTANT: colors H{
 
 : color>ansi ( color -- ansi bold? )
     color>rgb '[ _ distance ]
-    colors [ keys swap infimum-by ] [ at ] bi
+    colors [ keys swap minimum-by ] [ at ] bi
     dup 8 >= [ 8 - t ] [ f ] if ;
 
 MEMO: color>foreground ( color -- string )
index c269c73c3c8a98e71d9e6c4461e751bb984b9067..a62d0e102beca7251a896fc3199fab3f9ac6204f 100644 (file)
@@ -13,7 +13,7 @@ TUPLE: bin items total ;
     V{ } clone 0 bin boa ; inline
 
 : smallest-bin ( bins -- bin )
-    [ total>> ] infimum-by ; inline
+    [ total>> ] minimum-by ; inline
 
 : add-to-bin ( item weight bin -- )
     [ + ] change-total items>> push ;
index 91f322b9f0ad88b04aa8dd17555b955189909890..73c37f9edfc2a8f76cd13cc9fd71711363880d62 100644 (file)
@@ -66,6 +66,6 @@ IN: project-euler.066
 
 : euler066 ( -- D )
     1000 [1..b] [ perfect-square? ] reject
-    [ minimal-x ] supremum-by ;
+    [ minimal-x ] maximum-by ;
 
 SOLUTION: euler066
index 49d9ab2d763e12c6982d7f3753883b4e85289cce..ae8a3b6b0d303974b7e0db70aa7e5b0d2b716e65 100644 (file)
@@ -7,7 +7,7 @@ IN: rosetta-code.multisplit
 : first-subseq ( seq separators -- n separator )
     tuck
     [ [ subseq-index ] dip 2array ] withd map-index sift-keys
-    [ drop f f ] [ [ first ] infimum-by first2 rot nth ] if-empty ;
+    [ drop f f ] [ [ first ] minimum-by first2 rot nth ] if-empty ;
 
 : multisplit ( string separators -- seq )
     '[