\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#255: Add 'min' and 'max' [expr] Functions}
\date{July 21, 2005}
\author{Jeff Hobbs}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#255}&\textbf{Add 'min' and 'max' [expr] Functions}\\\hline
Author&

Jeff Hobbs \tipmail{jeffh}{activestate.com}
\\
Created&Thursday, \(\text{21}^{\text{st}}\) July 2005\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.6 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes enhancing the Tcl \textbf{expr} command with \textbf{min} and \textbf{max} functions.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{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.

\section{Specification}

The \textbf{min} and \textbf{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 \textbf{expr} function style (see \cite{tip232}). 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).

\section{Examples}
\begingroup\small\begin{verbatim}
 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
\end{verbatim}
\endgroup

\section{Reference Implementation}

[To be uploaded to SourceForge and URL added to this TIP.]

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\begin{thebibliography}{TIP \#1}
\addcontentsline{toc}{section}{References}
\bibitem[TIP \#232]{tip232}
Arjen Markus,
Kevin Kenny,
\emph{Creating New Math Functions for the 'expr' Command},
on-line at \url{http://purl.org/tcl/tip/232.html}
\end{thebibliography}
\end{document}
