summaryrefslogtreecommitdiffstats
path: root/library/init.tcl
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-10-08 13:44:37 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-10-08 13:44:37 (GMT)
commitba7edb67f66f3ae93d7c0ba267d77f5fbcf285f4 (patch)
tree11e807013d92abd0901f25d1b5377d6b4276d8a8 /library/init.tcl
parent9257d59dfb725123d0783a0584e0af27eb45c998 (diff)
downloadtcl-kennykb_numerics_branch.zip
tcl-kennykb_numerics_branch.tar.gz
tcl-kennykb_numerics_branch.tar.bz2
merge updates from HEAD kennykb_numerics_branch
Diffstat (limited to 'library/init.tcl')
-rw-r--r--library/init.tcl38
1 files changed, 37 insertions, 1 deletions
diff --git a/library/init.tcl b/library/init.tcl
index 020ea30..e9599ff 100644
--- a/library/init.tcl
+++ b/library/init.tcl
@@ -3,7 +3,7 @@
# Default system startup file for Tcl-based applications. Defines
# "unknown" procedure and auto-load facilities.
#
-# RCS: @(#) $Id: init.tcl,v 1.69.2.6 2005/09/15 20:58:40 dgp Exp $
+# RCS: @(#) $Id: init.tcl,v 1.69.2.7 2005/10/08 13:44:37 dgp Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -95,6 +95,42 @@ namespace eval tcl {
truncate ::tcl::chan::Truncate
}
}
+
+ # TIP #255 min and max functions
+ namespace eval mathfunc {
+ proc min {args} {
+ if {[llength $args] == 0} {
+ return -code error \
+ "too few arguments to math function \"min\""
+ }
+ set val Inf
+ foreach arg $args {
+ # This will handle forcing the numeric value without
+ # ruining the internal type of a numeric object
+ if {[catch {expr {double($arg)}} err]} {
+ return -code error $err
+ }
+ if {$arg < $val} { set val $arg }
+ }
+ return $val
+ }
+ proc max {args} {
+ if {[llength $args] == 0} {
+ return -code error \
+ "too few arguments to math function \"max\""
+ }
+ set val -Inf
+ foreach arg $args {
+ # This will handle forcing the numeric value without
+ # ruining the internal type of a numeric object
+ if {[catch {expr {double($arg)}} err]} {
+ return -code error $err
+ }
+ if {$arg > $val} { set val $arg }
+ }
+ return $val
+ }
+ }
}
# Windows specific end of initialization