I' m trying to make an animation with the following code
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\section{Bilder}
\begin{frame}
\begin{tikzpicture}
[pedestrian/.style={circle,draw=blue!50,fill=blue!20,thick},
transition/.style={rectangle,draw=black!50,fill=black!20,thick}]
\draw[step=1cm,gray,very thin] (-6,0) grid (3,1) ;
\let\mylist\empty
\foreach \x[count=\i] in {1,...,5}{
\node<\i> [gray,above] at (-7,0.2) {$step=\i$};
\pgfmathtruncatemacro\y{6-\i}
\foreach \x in {1,...,\y}
\node<\i> at (-6.5+\x, 0.5) [pedestrian] {\tiny{\x,\i,\y|\mylist}};
\ifx\mylist\empty
\xdef\mylist{5};
\else
\foreach \z in \mylist{
\node<\i> at (-2.5+\i , 0.5) [pedestrian] {\tiny{\z}};
}
\xdef\mylist{\y,\mylist};
\fi
}
\end{tikzpicture}
\end{frame}
\end{document}
Something is wrong with the variable z which is alway 5. I checked the values of mylist, which keeps growing, but still... z is always 5 (the last element of the list).
Here is the result that I was expecting: PDF-FILE
I got it by doing some stupid copy-paste
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgffor}
\begin{document}
\section{Bilder}
\begin{frame}
\begin{tikzpicture}
[pedestrian/.style={circle,draw=blue!50,fill=blue!20,thick},
transition/.style={rectangle,draw=black!50,fill=black!20,thick}]
\draw[step=1cm,gray,very thin] (-6,0) grid (3,1) ;
\uncover<1>{
\node [gray,above] at (-7,0.2) {$step=0$};
\foreach \x in {1,...,5}
\node at (-6.5+\x + 0, 0.5) [pedestrian] {\tiny{\x}};
}
\uncover<2>{
\node [gray,above] at (-7,0.2) {$i=5$};
\foreach \x in {1,...,4}
\node at (-6.5+\x + 0, 0.5) [pedestrian] {\tiny{\x}};
\node at (-6.5+6 + 0, 0.5) [pedestrian] {\tiny{5}};
}
\uncover<3>{
\node [gray,above] at (-7,0.2) {$i=4$};
\foreach \x in {1,...,3}
\node at (-6.5+\x + 0, 0.5) [pedestrian] {\tiny{\x}};
\foreach \x in {4,...,5}
\node at (-6.5+1 + \x, 0.5) [pedestrian] {\tiny{\x}};
}
\uncover<4>{
\node [gray,above] at (-7,0.2) {$i=3$};
\foreach \x in {1,...,2}
\node at (-6.5+\x + 0, 0.5) [pedestrian] {\tiny{\x}};
\foreach \x in {3,...,5}
\node at (-6.5+1 + \x, 0.5) [pedestrian] {\tiny{\x}};
}
\uncover<5>{
\node [gray,above] at (-7,0.2) {$i=2$};
\foreach \x in {2,...,5}
\node at (-6.5+1 + \x, 0.5) [pedestrian] {\tiny{\x}};
\node at (-6.5 + 1, 0.5) [pedestrian] {\tiny{1}};
}
\uncover<6>{
\node [gray,above] at (-7,0.2) {$i = 1$};
\foreach \x in {1,...,5}
\node at (-6.5+1 + \x, 0.5) [pedestrian] {\tiny{\x}};
}
\end{tikzpicture}
\end{frame}
\end{document}

\let\mylist\empty, and then you check if it is\emptywhich executes\xdef\mylist{5}. Plus you seem to be missing a{after the\foreach. Without that only the\nodeis executed, and the\xdef\mylist{\y,\mylist}only gets exectuted after the\foreachis complete. – Peter Grill Nov 18 '14 at 01:25else. Only thenodeshould be inforeach. – Tengis Nov 18 '14 at 01:28\expandafter\gdef\expandafter\mylist\expandafter{\mylist,\y}%– percusse Nov 18 '14 at 01:40{1,2,3}. At the end it will be just 3 – Tengis Nov 18 '14 at 01:52