]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: more supremum/infimum renames
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 23 Oct 2023 17:53:32 +0000 (10:53 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 23 Oct 2023 17:53:32 +0000 (10:53 -0700)
basis/ui/baseline-alignment/baseline-alignment.factor
basis/ui/gadgets/packs/packs.factor
extra/project-euler/150/150.factor
extra/sequences/extras/extras-docs.factor
extra/sequences/extras/extras-tests.factor
extra/sequences/extras/extras.factor

index dae432019f42c665a88f44eccf50ad23cef01417..7b2bba96a8dd95dfeddce7e53bb3a33a316c8dd9 100644 (file)
@@ -42,20 +42,20 @@ TUPLE: gadget-metrics height ascent descent cap-height ;
     [ dup [ 2dup - ] [ f ] if ] dip
     gadget-metrics boa ; inline
 
-: ?supremum ( seq -- n/f )
-    sift [ f ] [ supremum ] if-empty ;
+: ?maximum ( seq -- n/f )
+    sift [ f ] [ maximum ] if-empty ;
 
 : max-ascent ( seq -- n/f )
-    [ ascent>> ] map ?supremum ;
+    [ ascent>> ] map ?maximum ;
 
 : max-cap-height ( seq -- n/f )
-    [ cap-height>> ] map ?supremum ;
+    [ cap-height>> ] map ?maximum ;
 
 : max-descent ( seq -- n/f )
-    [ descent>> ] map ?supremum ;
+    [ descent>> ] map ?maximum ;
 
 : max-graphics-height ( seq -- n )
-    [ ascent>> ] reject [ height>> ] map ?supremum 0 or ;
+    [ ascent>> ] reject [ height>> ] map ?maximum 0 or ;
 
 :: combine-metrics ( graphics-height ascent descent cap-height -- ascent' descent' )
     ascent [
index 017911c099cf6529ace0ed8440ae5e5318e5a868..faf74986c1b50149c31cafe555bec91f53b849c2 100644 (file)
@@ -81,7 +81,7 @@ M: pack pref-dim*
     children>> dup pref-dims measure-metrics drop ; inline
 
 : pack-cap-height ( pack -- n/f )
-    children>> [ cap-height ] map ?supremum ; inline
+    children>> [ cap-height ] map ?maximum ; inline
 
 PRIVATE>
 
index acd10c4f2b8b8618784562f3f19a35bca685fb64..1599bb6cac35f3dfc0674d45ff786d6dbdd89782 100644 (file)
@@ -36,10 +36,10 @@ IN: project-euler.150
 : partial-sums ( seq -- sums )
     cum-sum 0 prefix ; inline
 
-: partial-sum-infimum ( seq quot -- seq )
+: partial-sum-minimum ( seq quot -- seq )
     [ 0 0 ] 2dip [ + [ min ] keep ] compose each drop ; inline
 
-: map-infimum ( seq quot -- min )
+: map-minimum ( seq quot -- min )
     [ min ] compose 0 swap reduce ; inline
 
 ! triangle generator functions
@@ -58,9 +58,9 @@ IN: project-euler.150
                 x z + table nth-unsafe
                 [ y z + 1 + swap nth-unsafe ]
                 [ y         swap nth-unsafe ] bi -
-            ] partial-sum-infimum
-        ] map-infimum
-    ] map-infimum ; inline
+            ] partial-sum-minimum
+        ] map-minimum
+    ] map-minimum ; inline
 
 PRIVATE>
 
index 4019aa4138a38a0c3e1c09833586e3602db4f859..d7e8ac83048e36b68f451cf265bc48741999532f 100644 (file)
@@ -7,7 +7,7 @@ HELP: pad-center
 { $description "Outputs a new sequence consisting of " { $snippet "seq" } " padded on the left and right with enough repetitions of " { $snippet "elt" } " to have the result be of length " { $snippet "n" } "." }
 { $examples { $example "USING: io sequences sequences.extras ;" "{ \"ab\" \"quux\" } [ 5 CHAR: - pad-center print ] each" "-ab--\nquux-" } } ;
 
-HELP: ?supremum
+HELP: ?maximum
 { $values
     { "seq/f" { $maybe sequence } }
     { "elt/f" { $maybe object } }
@@ -15,11 +15,11 @@ HELP: ?supremum
 { $description "Outputs the greatest element of " { $snippet "seq" } ", ignoring any " { $link POSTPONE: f } " elements in it. If " { $snippet "seq" } " is empty or " { $link POSTPONE: f } ", returns " { $link POSTPONE: f } "." }
 { $examples
     { $example "USING: prettyprint sequences.extras ;"
-    "{ 1 f 3 2 } ?supremum ."
+    "{ 1 f 3 2 } ?maximum ."
     "3" }
 } ;
 
-HELP: ?infimum
+HELP: ?minimum
 { $values
     { "seq/f" { $maybe sequence } }
     { "elt/f" { $maybe object } }
@@ -27,11 +27,11 @@ HELP: ?infimum
 { $description "Outputs the least element of " { $snippet "seq" } ", ignoring any " { $link POSTPONE: f } " elements in it. If " { $snippet "seq" } " is empty or " { $link POSTPONE: f } ", returns " { $link POSTPONE: f } "." }
 { $examples
     { $example "USING: prettyprint sequences.extras ;"
-    "{ 1 f 3 2 } ?infimum ."
+    "{ 1 f 3 2 } ?minimum ."
     "1" }
 } ;
 
-{ ?supremum ?infimum } related-words
+{ ?maximum ?minimum } related-words
 
 HELP: 2count
 { $values
index b63313fe5199fb634fa193df80da3bb1d483b178..74180a963ad6ddb5c10b99d685e13476e1e46dd8 100644 (file)
@@ -190,8 +190,8 @@ strings tools.test ;
 { V{ 0 4 } } [ { 5 3 2 10 5 } [ 5 = ] arg-where ] unit-test
 { { 2 1 0 4 3 } } [ { 5 3 2 10 5 } arg-sort ] unit-test
 
-{ 10 } [ { 4 3 2 1 } [ 10 * ] map-infimum ] unit-test
-{ 40 } [ { 4 3 2 1 } [ 10 * ] map-supremum ] unit-test
+{ 10 } [ { 4 3 2 1 } [ 10 * ] map-minimum ] unit-test
+{ 40 } [ { 4 3 2 1 } [ 10 * ] map-maximum ] unit-test
 
 { t } [ { 1 2 3 4 5 } 1 first= ] unit-test
 { t } [ { 1 2 3 4 5 } 2 second= ] unit-test
@@ -271,16 +271,16 @@ strings tools.test ;
 { 1 "beef" } [ { "chicken" "beef" "moose" } [ length ] minimum-by* ] unit-test
 { 0 "chicken" } [ { "chicken" "beef" "moose" } [ length ] maximum-by* ] unit-test
 { 2 "moose" } [ { "chicken" "beef" "moose" } [ first ] maximum-by* ] unit-test
-{ f } [ f ?supremum ] unit-test
-{ f } [ { } ?supremum ] unit-test
-{ f } [ { f } ?supremum ] unit-test
-{ 3 } [ { 1 f 3 2 } ?supremum ] unit-test
-{ 3 } [ { 1 3 2 } ?supremum ] unit-test
-{ f } [ f ?infimum ] unit-test
-{ f } [ { } ?infimum ] unit-test
-{ f } [ { f } ?infimum ] unit-test
-{ 1 } [ { 1 f 3 2 } ?infimum ] unit-test
-{ 1 } [ { 1 3 2 } ?infimum ] unit-test
+{ f } [ f ?maximum ] unit-test
+{ f } [ { } ?maximum ] unit-test
+{ f } [ { f } ?maximum ] unit-test
+{ 3 } [ { 1 f 3 2 } ?maximum ] unit-test
+{ 3 } [ { 1 3 2 } ?maximum ] unit-test
+{ f } [ f ?minimum ] unit-test
+{ f } [ { } ?minimum ] unit-test
+{ f } [ { f } ?minimum ] unit-test
+{ 1 } [ { 1 f 3 2 } ?minimum ] unit-test
+{ 1 } [ { 1 3 2 } ?minimum ] unit-test
 
 { 3/10 } [ 10 <iota> [ 3 < ] percent-of ] unit-test
 
index 07239ed9171574e767adab1e45c53af8da73ff78..05cf6cdf76e6cdd8c9b77e4abb85abf3bc2236b0 100644 (file)
@@ -905,22 +905,28 @@ ALIAS: infimum-by* minimum-by* deprecated
 : arg-min ( seq -- n )
     [ ] minimum-by* drop ;
 
-: ?supremum ( seq/f -- elt/f )
+: ?maximum ( seq/f -- elt/f )
     [ f ] [
         [ ] [ 2dup and [ max ] [ dupd ? ] if ] map-reduce
     ] if-empty ;
 
-: ?infimum ( seq/f -- elt/f )
+: ?minimum ( seq/f -- elt/f )
     [ f ] [
         [ ] [ 2dup and [ min ] [ dupd ? ] if ] map-reduce
     ] if-empty ;
 
-: map-infimum ( seq quot: ( ... elt -- ... elt' ) -- elt' )
+ALIAS: ?supremum ?maximum deprecated
+ALIAS: ?infimum ?minimum deprecated
+
+: map-minimum ( seq quot: ( ... elt -- ... elt' ) -- elt' )
     [ min ] map-reduce ; inline
 
-: map-supremum ( seq quot: ( ... elt -- ... elt' ) -- elt' )
+: map-maximum ( seq quot: ( ... elt -- ... elt' ) -- elt' )
     [ max ] map-reduce ; inline
 
+ALIAS: map-supremum map-maximum deprecated
+ALIAS: map-infimum map-minimum deprecated
+
 : change-last ( seq quot -- )
     [ index-of-last ] [ change-nth ] bi* ; inline