TikZ - Compute the array being the min of 2 arrays

I define 2 arrays r and p and draw them.

I would like now to compute the min of r and p in order to draw it in a similar way. The resulting array would be {0.2, 0.4, 0.8, 0.8, 0.4, 0.0, 0.1, 0.0, 0.1 ,0.5}, but I would like to compute it automatically.

Do you have any idea ?

Here is a MWE regardig the definition and the drawing of r and p :

\begin{tikzpicture}
\def\r{{0.2}, {0.4}, {1.0}, {0.8}, {1.0}, {0.0}, {0.3}, {0.5}, {0.1}, {0.5}};
\def\p{{0.9}, {0.5}, {0.8}, {0.8}, {0.4}, {0.3}, {0.1}, {0.0}, {0.8}, {0.7}};

\filldraw (0, 0.2) node {$r$}
\foreach \y [count=\x from 0] in \r { -- (\x, \y) circle[radius=1pt] };
\filldraw (0, 0.9) node {$r$}
\foreach \y [count=\x from 0] in \p { -- (\x, \y) circle[radius=1pt] };

\end{tikzpicture}
• Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important for tikz as there are numerous libraries. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – Peter Grill Nov 7 '14 at 17:00

Basic idea is to iterate through the first list and locate the nth member of the second list and save the minimum into another list. Code:

\documentclass{article}
\usepackage{tikz}

%% https://tex.stackexchange.com/questions/14393/how-keep-a-running-list-of-strings-and-then-process-them-one-at-a-time
\makeatletter
\newcommand*\@NewList{}%
\newcommand{\ApendToNewList}{%
\begingroup\edef\TempValue{\endgroup%
}

\newcommand*{\ExtractNthValueOfList}{%
\foreach [count=\i from 1] \x in #3 {%
\ifnum\i=#2\relax
\xdef#1{\x}%
\breakforeach%
\fi
}%
}

\newcommand*{\@NthValue}{xx}
\newcommand*{\ExtractMinList}{
% #1 = variable to contain extract list
% #2 = first list
% #3 = second list
\foreach [count=\j from 1] \y in #2 {%
\ExtractNthValueOfList{\@NthValue}{\j}{#3}%
\pgfmathsetmacro{\MinValue}{min(\y,\@NthValue)}%
\ApendToNewList{\MinValue}%
\typeout{\j, \y, \@NthValue}% <--- Useful for debugging
}%
\edef#1{\@NewList}%
}
\makeatother

\newcommand\RList{{0.2}, {0.4}, {1.0}, {0.8}, {1.0}, {0.0}, {0.3}, {0.5}, {0.1}, {0.5}}
\newcommand\PList{{0.9}, {0.5}, {0.8}, {0.8}, {0.4}, {0.3}, {0.1}, {0.0}, {0.8}, {0.7}}
\newcommand\ExtractedMinList{}% Ensure that we are not overwriting an existing macro

\begin{document}
\ExtractMinList{\ExtractedMinList}{\RList}{\PList}%
Extracted List=\ExtractedMinList
\end{document}
• Thank you very much ! Moreover, the ExtractNthValueOfList allows me to extract the first value for the \filldraw loop. – Gim Nov 8 '14 at 10:49