Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.189.2.38 -r1.189.2.39 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 29 Nov 2019 11:12:34 -0000 1.189.2.38 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 29 Nov 2019 13:50:46 -0000 1.189.2.39 @@ -2792,12 +2792,45 @@ } } -ad_proc -public min { args } { +ad_proc -deprecated min { args } { Returns the minimum of a list of numbers. Example: min 2 3 1.5 returns 1.5. + DEPRECATED: this proc does not respect OpenACS naming convention. + @see util::min + @author Ken Mayer (kmayer@bitwrangler.com) @creation-date 26 September 2002 } { + return [util::min $args] +} + + +ad_proc -deprecated max { args } { + Returns the maximum of a list of numbers. Example: max 2 3 1.5 returns 3. + + DEPRECATED: this proc does not respect OpenACS naming convention. + @see util::max + + @author Lars Pind (lars@pinds.com) + @creation-date 31 August 2000 +} { + return [util::max $args] +} + +ad_proc -public util::min { args } { + Returns the minimum of a list of numbers. Example: min 2 3 1.5 returns 1.5. + + Since Tcl8.5, numerical min and max are among the math functions + supported by expr. The reason why this proc is still around is + that it supports also non-numerical values in the list, in a way + that is not so easily replaceable by a lsort idiom (but could). + + @see expr + @see lsort + + @author Ken Mayer (kmayer@bitwrangler.com) + @creation-date 26 September 2002 +} { set min [lindex $args 0] foreach arg $args { if { $arg < $min } { @@ -2808,9 +2841,17 @@ } -ad_proc -public max { args } { +ad_proc -public util::max { args } { Returns the maximum of a list of numbers. Example: max 2 3 1.5 returns 3. + Since Tcl8.5, numerical min and max are among the math functions + supported by expr. The reason why this proc is still around is + that it supports also non-numerical values in the list, in a way + that is not so easily replaceable by a lsort idiom (but could). + + @see expr + @see lsort + @author Lars Pind (lars@pinds.com) @creation-date 31 August 2000 } { Index: openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl,v diff -u -r1.71.2.19 -r1.71.2.20 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 29 Nov 2019 11:12:34 -0000 1.71.2.19 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 29 Nov 2019 13:50:46 -0000 1.71.2.20 @@ -913,26 +913,28 @@ aa_register_case \ -cats {api smoke production_safe} \ -procs { - min - max + util::min + util::max } \ min_max { - Test min and max procs + Test util::min and util::max procs @creation-date 2018-09-18 @author Héctor Romojaro } { - aa_equals "Empty value" [min {}] {} - aa_equals "Empty value" [max {}] {} - aa_equals "1" [min 1] {1} - aa_equals "1" [max 1] {1} - aa_equals "1 0 -1" [min 1 0 -2] {-2} - aa_equals "1 0 -1" [max 1 0 -2] {1} - aa_equals "0 0.89 -0.89 -1" [min 0 0.89 -0.89 -1] {-1} - aa_equals "0 0.89 -0.89 -1" [max 0 0.89 -0.89 -1] {0.89} - aa_equals "3 1000 0 -3 -2000" [min 3 1000 0 -3 -2000] {-2000} - aa_equals "3 1000 0 -3 -2000" [max 3 1000 0 -3 -2000] {1000} + aa_equals "Empty value" [util::min {}] {} + aa_equals "Empty value" [util::max {}] {} + aa_equals "1" [util::min 1] {1} + aa_equals "1" [util::max 1] {1} + aa_equals "1 0 -1" [util::min 1 0 -2] {-2} + aa_equals "1 0 -1" [util::max 1 0 -2] {1} + aa_equals "0 0.89 -0.89 -1" [util::min 0 0.89 -0.89 -1] {-1} + aa_equals "0 0.89 -0.89 -1" [util::max 0 0.89 -0.89 -1] {0.89} + aa_equals "3 1000 0 -3 -2000" [util::min 3 1000 0 -3 -2000] {-2000} + aa_equals "3 1000 0 -3 -2000" [util::max 3 1000 0 -3 -2000] {1000} + aa_equals "1 2 z a b 6" [util::max 1 2 z a b 6] z + aa_equals "1 2 z a b 6" [util::min 1 2 z a b 6] 1 } aa_register_case \