I'm trying a small educational example using pgfmath. I want to calculate the minimum of a list of numbers.
More accurately, I have a list of (number,string)-pairs, and I want the minimum of all the numbers.
My \calculateMin command (see below) first uses a \foreach loop to build up a temporary list comprising just the first components. It then takes the minimum of that using pgfmath's built-in min function.
Code
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand*\calculateMin[1]{%
\def\mylist{}%
\foreach \i/\j in {#1} {%
\edef\mylist{\mylist,\i}%
}%
\pgfmathparse{min(\mylist)}\pgfmathresult%
}
Minimum of (8/ignore,7/this,2/second,5/component)
is \calculateMin{8/ignore,7/this,2/second,5/component}.
\end{document}
Result
Minimum of (8/ignore,7/this,2/second,5/component) is 16383.0.
The result should be "2". What's going on?
