]
: alphabet-inverse ( alphabet -- seq )
- dup supremum 1 + f <array> [
+ dup maximum 1 + f <array> [
'[ swap _ set-nth ] each-index
] keep ;
>>
<bit-array> [ '[ [ t ] dip _ set-nth ] each ] keep ;
: largest-spill-slot ( seqs -- n )
- concat [ 0 ] [ supremum 1 + ] if-empty ;
+ concat [ 0 ] [ maximum 1 + ] if-empty ;
: emit-gc-roots ( seqs -- n )
! seqs is a sequence of sequences of integers 0..n-1
} 1&& ;
: lookup-table-seq ( assoc -- table )
- [ keys supremum 1 + <iota> ] keep '[ _ at ] { } map-as ;
+ [ keys maximum 1 + <iota> ] keep '[ _ at ] { } map-as ;
: lookup-table-quot ( seq -- newquot )
lookup-table-seq
lit-vec get build-dicts
dist-dict set
lit-dict set
- lit-code-lens supremum 16 < clen-seq supremum 8 < and
+ lit-code-lens maximum 16 < clen-seq maximum 8 < and
[ drop dynamic-headers clen-bits compressed-lens
lit-vec get vec-to-codes deflate-block boa ]
[ halves [ (compress-dynamic) ] bi@ 2array ] if
[ writes>> keys ] [ write-fdset>> ] bi ;
: max-fd ( assoc -- n )
- dup assoc-empty? [ drop 0 ] [ keys supremum ] if ;
+ dup assoc-empty? [ drop 0 ] [ keys maximum ] if ;
: num-fds ( mx -- n )
[ reads>> max-fd ] [ writes>> max-fd ] bi max 1 + ;
: matrix-l-infinity-norm ( m -- n )
dup zero-matrix? [ drop 0 ] [
- [ [ abs ] map-sum ] map supremum
+ [ [ abs ] map-sum ] map maximum
] if ; inline foldable
: matrix-l1-norm ( m -- n )
[ { 1 2 3 4 5 6 } 3 <windowed-sequence> length ] unit-test
{ { 1 1 1 2 3 4 } }
-[ { 1 2 3 4 5 6 } 3 <windowed-sequence> [ infimum ] map ] unit-test
+[ { 1 2 3 4 5 6 } 3 <windowed-sequence> [ minimum ] map ] unit-test
: rolling-median ( seq n -- newseq )
[ median ] rolling-map ;
-: rolling-supremum ( seq n -- newseq )
- [ supremum ] rolling-map ;
+: rolling-maximum ( seq n -- newseq )
+ [ maximum ] rolling-map ;
-: rolling-infimum ( seq n -- newseq )
- [ infimum ] rolling-map ;
+: rolling-minimum ( seq n -- newseq )
+ [ minimum ] rolling-map ;
+
+ALIAS: rolling-supremum rolling-maximum deprecated
+ALIAS: rolling-infimum rolling-minimum deprecated
: rolling-count ( ... u n quot: ( ... elt -- ... ? ) -- ... v )
'[ _ count ] rolling-map ; inline
: unify-branches ( ins stacks -- in phi-in phi-out )
zip [ 0 { } { } ] [
- [ keys supremum ] [ ] [ balanced? ] tri
+ [ keys maximum ] [ ] [ balanced? ] tri
[ dupd phi-inputs dup phi-outputs ] [
[ combinator get quotations get ] dip
simple-unbalanced-branches-error
: datastack-phi ( seq -- phi-in phi-out )
[ input-count branch-variable ]
- [ inner-d-index branch-variable infimum inner-d-index set ]
+ [ inner-d-index branch-variable minimum inner-d-index set ]
[ (meta-d) active-variable ] tri
unify-branches
[ input-count set ] [ ] [ dup >vector (meta-d) set ] tri* ;
[ sum nanos>string ]
[ mean >integer nanos>string ]
[ median >integer nanos>string ]
- [ infimum nanos>string ]
- [ supremum nanos>string ]
+ [ minimum nanos>string ]
+ [ maximum nanos>string ]
} cleave
] bi
] bi
: contiguous-range? ( keys -- ? )
dup [ fixnum? ] all? [
dup all-unique? [
- [ length ] [ supremum ] [ infimum ] tri - - 1 =
+ [ length ] [ maximum ] [ minimum ] tri - - 1 =
] [ drop f ] if
] [ drop f ] if ;
: dispatch-case-quot ( default assoc -- quot )
swap [
- [ keys [ infimum ] [ supremum ] bi over ]
+ [ keys [ minimum ] [ maximum ] bi over ]
[ sort-keys values [ >quotation ] map ] bi
] dip dup '[
dup integer? [
M: tuple-dispatch-engine compile-engine
tuple assumed [
echelons>> compile-engines
- dup keys supremum 1 + f <array>
+ dup keys maximum 1 + f <array>
<enumerated> swap assoc-union! seq>>
] with-variable ;
{ $values { "seq" { $sequence number } } { "n" number } }
{ $description "Outputs the product of all elements of " { $snippet "seq" } ". Outputs one given an empty sequence." } ;
-HELP: infimum
+HELP: minimum
{ $values { "seq" sequence } { "elt" object } }
{ $description "Outputs the least element of " { $snippet "seq" } "." }
{ $examples
"Example:"
{ $example "USING: sequences prettyprint ;"
- "{ 1 2 3 4 5 } infimum ."
+ "{ 1 2 3 4 5 } minimum ."
"1"
}
"Example:"
{ $example "USING: sequences prettyprint ;"
- "{ \"c\" \"b\" \"a\" } infimum ."
+ "{ \"c\" \"b\" \"a\" } minimum ."
"\"a\""
}
}
}
{ $errors "Throws an error if the sequence is empty." } ;
-HELP: supremum
+HELP: maximum
{ $values { "seq" sequence } { "elt" object } }
{ $description "Outputs the greatest element of " { $snippet "seq" } "." }
{ $examples
"Example:"
{ $example "USING: sequences prettyprint ;"
- "{ 1 2 3 4 5 } supremum ."
+ "{ 1 2 3 4 5 } maximum ."
"5"
}
"Example:"
{ $example "USING: sequences prettyprint ;"
- "{ \"c\" \"b\" \"a\" } supremum ."
+ "{ \"c\" \"b\" \"a\" } maximum ."
"\"c\""
}
}
}
{ $errors "Throws an error if the sequence is empty." } ;
-{ min max infimum infimum-by supremum supremum-by } related-words
+{ min max minimum infimum-by maximum supremum-by } related-words
HELP: shortest
{ $values { "seqs" sequence } { "elt" object } }
}
"Superlatives with " { $link min } " and " { $link max } ":"
{ $subsections
- infimum
+ minimum
infimum-by
- supremum
+ maximum
supremum-by
shorter
longer
{ 24 } [ { 1 2 } { 3 4 } [ + ] [ * ] 2map-reduce ] unit-test
{ 2 96 } [ 2 { 3 3 3 3 } { 4 4 4 4 } [ [ dup ] 2dip * * ] [ + ] 2map-reduce ] unit-test
-{ 4 } [ 5 <iota> supremum ] unit-test
-{ 0 } [ 5 <iota> infimum ] unit-test
{ 4 } [ 5 <iota> maximum ] unit-test
{ 0 } [ 5 <iota> minimum ] unit-test
SYMBOL: benchmarks-disabled?
: run-timing-benchmark ( vocab -- time )
- 5 swap '[ gc [ _ run ] benchmark ] replicate infimum ;
+ 5 swap '[ gc [ _ run ] benchmark ] replicate minimum ;
: run-profile-benchmark ( vocab -- profile )
compact-gc '[ _ run ] profile most-recent-profile-data ;
: available? ( vn -- ? ) basic-block get avail-in key? ;
: best-vreg ( available-vregs -- vreg )
- [ f ] [ infimum ] if-empty ;
+ [ f ] [ minimum ] if-empty ;
: >avail-vreg ( vreg -- vreg/f )
final-iteration? get [
[
[ days>> 1 ] [ months>> ] bi [
{ 0 31 29 31 30 31 30 31 31 30 31 30 31 } nth
- ] map supremum [ between? ] 2curry all?
+ ] map maximum [ between? ] 2curry all?
]
[ minutes>> [ 0 59 between? ] all? ]
[ hours>> [ 0 23 between? ] all? ]
[ rfc822>timestamp timestamp>unix-time ] map-keys ;
: grouped-crons. ( assoc -- )
- keys-unix-to-rfc822 [ first2 [ write bl ] [ ... ] bi* ] each ;
\ No newline at end of file
+ keys-unix-to-rfc822 [ first2 [ write bl ] [ ... ] bi* ] each ;
: chd ( chart seq -- chart )
[ x,y >>data ] [
- [ infimum 0 min ] [ supremum 0 max ] bi 2array
+ [ minimum 0 min ] [ maximum 0 max ] bi 2array
x,y >>data-scale
] bi ;
1 minkowski-distance ;
: chebyshev-distance ( a b -- n ) ! also chessboard-distance
- v- vabs supremum ;
+ v- vabs maximum ;
: cosine-distance ( a b -- n )
cosine-similarity 1 swap - ;
HELP: nan-min
{ $values { "seq" sequence } { "n" number } }
-{ $description "Return the " { $link infimum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
+{ $description "Return the " { $link minimum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
HELP: nan-max
{ $values { "seq" sequence } { "n" number } }
-{ $description "Return the " { $link supremum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
+{ $description "Return the " { $link maximum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
HELP: sinc
{ $values { "x" number } { "y" number } }
: moving-median ( u n -- v )
<clumps> [ median ] map ;
-: moving-supremum ( u n -- v )
- <clumps> [ supremum ] map ;
+: moving-maximum ( u n -- v )
+ <clumps> [ maximum ] map ;
-: moving-infimum ( u n -- v )
- <clumps> [ infimum ] map ;
+: moving-minimum ( u n -- v )
+ <clumps> [ minimum ] map ;
+
+ALIAS: moving-supremum moving-maximum deprecated
+ALIAS: moving-infimum moving-minimum deprecated
: moving-sum ( u n -- v )
<clumps> [ sum ] map ;
0 [ dup fp-nan? [ drop ] [ + ] if ] binary-reduce ;
: nan-min ( seq -- n )
- [ fp-nan? ] reject infimum ;
+ [ fp-nan? ] reject minimum ;
: nan-max ( seq -- n )
- [ fp-nan? ] reject supremum ;
+ [ fp-nan? ] reject maximum ;
: fill-nans ( seq -- newseq )
[ first ] keep [
M: div pdf-width
[ style>> set-style ] keep
- items>> [ dupd pdf-width ] map nip supremum ;
+ items>> [ dupd pdf-width ] map nip maximum ;
<PRIVATE
M: p pdf-width
[ style>> set-style ] keep
[ font>> ] [ string>> ] bi* split-lines
- [ dupd text-width ] map nip supremum ;
+ [ dupd text-width ] map nip maximum ;
TUPLE: text string style ;
M: text pdf-width
[ style>> set-style ] keep
[ font>> ] [ string>> ] bi* split-lines
- [ dupd text-width ] map nip supremum ;
+ [ dupd text-width ] map nip maximum ;
TUPLE: hr width ;
[
[
contents>> [ 0 ] [
- [ [ dupd pdf-width ] [ 0 ] if* ] map supremum
+ [ [ dupd pdf-width ] [ 0 ] if* ] map maximum
] if-empty
] [ 0 ] if*
] map nip ;
{ 0.5 0.520499877813 }
{ 2.1 0.997020533344 }
} [ [ first erf ] [ second - ] bi abs ] map
- supremum 1e-6 <
+ maximum 1e-6 <
] unit-test
{ t } [
{ $[ 1e-5 1e-8 + ] 0.00001001005010021717 }
{ 0.5 0.6487212707001282 }
} [ [ first expm1 ] [ second - ] bi abs ] map
- supremum 1e-6 <
+ maximum 1e-6 <
] unit-test
{ t } [
{ 0.5 0.691462461274 }
{ 2.1 0.982135579437 }
} [ [ first phi ] [ second - ] bi abs ] map
- supremum 1e-3 <
+ maximum 1e-3 <
] unit-test
: factorial ( n -- n! ) [ 1 ] [ [1..b] 1 [ * ] reduce ] if-zero ;
{ t } [
{ 0 1 10 100 1000 10000 } [
[ factorial log ] [ log-factorial ] bi - abs
- ] map supremum 1e-6 <
+ ] map maximum 1e-6 <
] unit-test
: relative-error ( approx value -- relative-error )
{ 12.001 40014424.1571 }
{ 15.2 149037380723.0 }
} [ [ first gamma ] [ second relative-error ] bi ] map
- supremum 1e-6 <
+ maximum 1e-6 <
] unit-test
{ t } [
{ 12.0001 17.5025521125 }
{ 27.4 62.5755868211 }
} [ [ first log-gamma ] [ second relative-error ] bi ] map
- supremum 1e-10 <
+ maximum 1e-10 <
] unit-test
: best-holdem-hand ( hand -- n cards )
5 [ [ hand-value ] [ ] bi ] { } map>assoc-combinations
- infimum first2 ;
+ minimum first2 ;
: value>string ( n -- string )
value>rank VALUES nth ;
n [
holes deck 5 sample '[
[ _ append best-holdem-hand drop ] keep
- ] { } map>assoc infimum second
+ ] { } map>assoc minimum second
] replicate histogram ;
: (best-omaha-hand) ( seq -- pair )
[ 2 all-combinations ] [ 3 all-combinations ] bi*
2array [ concat [ best-holdem-hand drop ] keep ] { } product-map>assoc ;
-: best-omaha-hand ( seq -- n cards ) (best-omaha-hand) infimum first2 ;
+: best-omaha-hand ( seq -- n cards ) (best-omaha-hand) minimum first2 ;
:: compare-omaha-hands ( holes deck n -- seq )
n [
holes deck 5 sample '[
[ _ append best-omaha-hand drop ] keep
- ] { } map>assoc infimum second
+ ] { } map>assoc minimum second
] replicate histogram ;
ERROR: bad-suit-symbol ch ;
! --------
: euler003 ( -- answer )
- 600851475143 factors supremum ;
+ 600851475143 factors maximum ;
! [ euler003 ] 100 ave-time
! 1 ms ave run time - 0.49 SD (100 trials)
[
{ [ horizontal ] [ vertical ] [ diagonal/ ] [ diagonal\ ] }
[ call( -- matrix ) 4 max-product , ] each
- ] { } make supremum ;
+ ] { } make maximum ;
! [ euler011 ] 100 ave-time
! 3 ms ave run time - 0.77 SD (100 trials)
<PRIVATE
: max-period ( seq -- elt n )
- dup [ period-length ] map dup supremum
+ dup [ period-length ] map dup maximum
over index [ swap nth ] curry bi@ ;
PRIVATE>
swap 0 (consecutive-primes) ;
: max-consecutive ( seq -- elt n )
- dup [ first2 consecutive-primes ] map dup supremum
+ dup [ first2 consecutive-primes ] map dup maximum
over index [ swap nth ] curry bi@ ;
PRIVATE>
PRIVATE>
: euler038 ( -- answer )
- 9123 9876 [a..b] [ concat-product ] map [ pandigital? ] filter supremum ;
+ 9123 9876 [a..b] [ concat-product ] map [ pandigital? ] filter maximum ;
! [ euler038 ] 100 ave-time
! 11 ms ave run time - 1.5 SD (100 trials)
PRIVATE>
: euler042 ( -- answer )
- source-042 [ alpha-value ] map dup supremum
+ source-042 [ alpha-value ] map dup maximum
triangle-upto [ member? ] curry count ;
! [ euler042 ] 100 ave-time
: ?register ( acc seq -- )
complete rotate-bits
- dup [ 2 N ^ mod ] map all-unique? [ infimum swap push ] [ 2drop ] if ;
+ dup [ 2 N ^ mod ] map all-unique? [ minimum swap push ] [ 2drop ] if ;
: add-bit ( seen bit -- seen' t/f )
over last 2 * + 2 N ^ mod
vocab-words flatten-generics
[ word-noise-factor dup 20 < [ drop 0 ] when ] map
[ 0 ] [
- [ [ sum ] [ length 5 max ] bi /i ]
- [ supremum ]
- bi +
+ [ [ sum ] [ length 5 max ] bi /i ] [ maximum ] bi +
] if-empty ;
: noisy-vocabs ( -- alist )
tetrominoes get random ;
: blocks-max ( blocks quot -- max )
- map supremum 1 + ; inline
+ map maximum 1 + ; inline
: blocks-width ( blocks -- width )
[ first ] blocks-max ;