<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://tcl.activestate.com/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Wed May 16 20:00:09 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='255'>
<header><title>Add &apos;min&apos; and &apos;max&apos; [expr] Functions</title><author address="mailto:jeffh@activestate.com">Jeff Hobbs</author><status type='project' state='final' tclversion="8.5" vote='after'>$Revision: 1.6 $</status><history></history><created day='21' month='jul' year='2005' /></header>
<abstract>This TIP proposes enhancing the Tcl <emph style="bold">expr</emph> command with <emph style="bold">min</emph> and <emph style="bold">max</emph> functions.</abstract>
<body><section title="Rationale">
<para>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&apos; 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.</para>
</section>
<section title="Specification">
<para>The <emph style="bold">min</emph> and <emph style="bold">max</emph> functions shall be created using Tcl commands (in a namespace such all namespaces will pick them up by default) in the new 8.5 <emph style="bold">expr</emph> function style (see <tipref type="text" 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).</para>
</section>
<section title="Examples">
<verbatim><vline encoding='base64'>IGV4cHIge21pbigwLDMsMSl9</vline><vline encoding='base64'>ID0+IDA=</vline><vline encoding='base64'>IGV4cHIge21heCg0LjIsIDB4Riwgd2lkZSgxKSl9</vline><vline encoding='base64'>ID0+IDE1LjA=</vline><vline encoding='base64'>IGV4cHIge21pbig0LjIpfQ==</vline><vline encoding='base64'>ID0+IDQuMg==</vline><vline encoding='base64'>IGV4cHIge21pbigpfQ==</vline><vline encoding='base64'>ID0+IHRvbyBmZXcgYXJndW1lbnRzIGZvciBtYXRoIGZ1bmN0aW9u</vline></verbatim>
</section>
<section title="Reference Implementation">
<para>[To be uploaded to SourceForge and URL added to this TIP.]</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

