TIP #255: ADD 'MIN' AND 'MAX' [EXPR] FUNCTIONS ================================================ Version: $Revision: 1.6 $ Author: Jeff Hobbs State: Final Type: Project Tcl-Version: 8.5 Vote: Done Created: Thursday, 21 July 2005 URL: https://tip.tcl-lang.org255.html Post-History: ------------------------------------------------------------------------- ABSTRACT ========== This TIP proposes enhancing the Tcl *expr* command with *min* and *max* functions. RATIONALE =========== Many programs need to find the minimum or maximum of a set of numbers, so having functions to do this will make many script programmers' lives easier. This will be adopting yet another feature from TclX, but with the minor enhancement of being able to handle arbitrary numbers of arguments. SPECIFICATION =============== The *min* and *max* functions shall be created using Tcl commands (in a namespace such all namespaces will pick them up by default) in the new 8.5 *expr* function style (see [TIP #232]). They will take one or more numeric arguments (of any valid numeric type) and return the minimum or maximum value of those numbers (depending on which function was invoked). EXAMPLES ========== expr {min(0,3,1)} => 0 expr {max(4.2, 0xF, wide(1))} => 15.0 expr {min(4.2)} => 4.2 expr {min()} => too few arguments for math function REFERENCE IMPLEMENTATION ========================== [To be uploaded to SourceForge and URL added to this TIP.] COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows