%\RequirePackage{atbegshi}
\documentclass[french]{beamer}
\usepackage{etex}

\usepackage[beamer,utf8x]{preambuleTrm}



\usepackage{iwona}


\newcommand{\py}[1]{\mintinline{python}{#1} 
}
\newcommand{\paratitre}{\frametitle}


\mode<presentation>
{
  %\usetheme{Bergen}%Montpellier
  % or ...Frankfurt, 
  \usetheme[secheader]{Madrid}

  \setbeamercovered{highly dynamic}
  % or whatever (possibly just delete it)
  \usefonttheme{progressbar}
  \useoutertheme{progressbar}
  %\useinnertheme{progressbar}
  \progressbaroptions{% titlepage=normal,
    imagename=/home/moi/Photos/Maths/popop
}
}

\usepackage{elephantbird}


%\usepackage[french,vlined,boxed]{algorithm2e}
\usepackage{bookmark,multido}
%\usepackage{xlop}

\ifpdf \DeclareGraphicsRule{*}{mps}{*}{} \fi
\usepackage{tikz}
\usetikzlibrary{automata,fit,trees,matrix,arrows,decorations.pathmorphing,shapes,arrows,chains,positioning,intersections,backgrounds,calc,through,mindmap,shadows,patterns,shapes.geometric}
%\newcommand{\myunit}{1.1cm}
%\usepackage{tkz-graph}
%\usepackage{circuitikz}
\usepackage{tikz-qtree}
\usepackage{tikz-uml}
\usepackage{tikz-cd}
\hypersetup{pdfpagemode=FullScreen}

\usepackage[detect-all]{siunitx}

\usepackage{caption}
\captionsetup{labelformat=empty,font=footnotesize}

\usepackage{scalefnt}

%\usepackage{multimedia}
% \usepackage{cclicenses}
% \usepackage{cclicence}
\setbeamertemplate{theorems}[numbered]

\usepackage[square]{daedale}
\bibliographystyle{cyclope}


\usepackage{algo}

\renewcommand{\algocommentfont}{\tiny\ttfamily\itshape}


\newtheorem{exercice}{Exercice}


\setlength{\columnseprule}{0pt}

%\setlength{\parskip}{0pt}


\graphicspath{{/home/moi/IUT/Figures/}{/home/moi/VISA_III/figures_visa/}{/home/moi/Lycee/TDmaple/2006_7/}{/home/moi/Figures/Arbres_Graphes/}{/home/moi/Figures/FigSTI/}{/home/moi/Figures/FigMaple/}{/home/moi/Photos/Maths/}{/home/moi/Photos/Tehessin/}{/home/moi/Figures/FigSTI/}{/home/moi/Figures/FigSeconde/}{/home/moi/Lycee/Informatique/XCAS/2008_9/}{/home/moi/Lycee/TDmaple/2008_9/}{/home/moi/IUT/Thierry/Conversions/}{/home/moi/Photos/informathix/}{/home/moi/Lycee/Informatique/PafAlgo/}{/home/moi/Figures/figuresAlice/}{/home/moi/Figures/FigSeconde/}{/home/moi/Biocam/robot/}{/home/moi/Biocam/CoursIni3d/}{/home/moi/Biocam/central/figures/}{/home/moi/Biocam/central/}{/home/moi/IUT/INFO2/Images/}{/home/moi/IUT/INFO2/2011_12/graphes/}{/home/moi/IUT/INFO1/CM1/}{/home/moi/Figures/figuresTS/}{/home/moi/Photos/Tehessin/}{/home/moi/Figures/FigSTI/}{/home/moi/Alice/figures3/}{/home/moi/Alice/figures3/newcourbes/}{/home/moi/Alice/figures/}{/home/moi/Figures/figuresAlice/}{/home/moi/Photos/Maths/}{/home/moi/Lycee/TS/}{/home/moi/Lycee/TS/2009_10/}{/home/moi/Figures/FigMaple/}{/home/moi/Figures/figuresTS/newcourbes/}{/home/moi/Figures/FigEspace/}{/home/moi/PROG/HASKELL/FLOAT/}{/home/moi/PREPA/IPT/2014_15/Poly/}}




\setcounter{tocdepth}{2} %\setcounter{page}{0}


\newcommand{\triangleup}{\Delta}













\begin{document}


\title[]% (optional, use only with long paper titles)
{Piles}

\subtitle{Informatique pour tou(te)s - semaines 39 \& 40}

\author[] % (optional, use only with lots of authors)
{Guillaume CONNAN }
% - Give the names in the same order as the appear in the paper.
% - Use the inst{?} command only if the authors have different
%   affiliation.

\institute{Lycée Clemenceau - MP / MP$^{\star}$}% (optional, but mostly needed)

%\logo{\includegraphics[width=0.1\textwidth]{logo_iut}}

%\logo{\includegraphics[scale=0.15]{big_connan}}

\date[] % (optional, should be abbreviation of conference name)
{septembre 2015}
% - Either use conference name or its abbreviation.
% - Not really informative to the audience, more for people (including
%   yourself) who are reading the slides online

\subject{ }


\beamerdefaultoverlayspecification{<+->}

% \AtBeginSubsubsection[]
% {
%   \begin{frame}<beamer>
%     \frametitle{Sommaire}
%  {\scriptsize
% \begin{multicols}{2}
%     \tableofcontents[currentsection,currentsubsection]
%        \end{multicols}
% }

%   \end{frame}
% }




% \AtBeginSubsection[]
% {\scriptsize
%   \begin{frame}<beamer>
%     \frametitle{Sommaire}
%  {\tiny
% \begin{multicols}{2}
%     \tableofcontents[currentsection,currentsubsection]
%        \end{multicols}
% }

%   \end{frame}
% }





% \AtBeginSection[]
% {
%   \begin{frame}<beamer>
%     \frametitle{Sommaire}
%  {\scriptsize
% \begin{multicols}{2}
%     \tableofcontents[currentsection]
%        \end{multicols}
% }

%   \end{frame}
% }


% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command: 

\beamerdefaultoverlayspecification{<+->}




\newcommand{\TR}{\mathcal{T}}


\begin{frame}
%\ThisCenterWallPaper{1}{logoiremBigInv}
 \Large \titlepage 
\end{frame}

% \begin{frame}
%  \frametitle{Sommaire}
% {\scriptsize
% \begin{multicols}{2} 
%  \tableofcontents
% \end{multicols}
% }

 
%  \end{frame}

\begin{frame}
 \frametitle{ Jan \textsc{\L ukasiewicz} (1878-1956)}

%\begin{figure}
\begin{center}
  \includegraphics[height=0.9\textheight]{lukasiewicz}
\end{center}
%\end{figure}
  
\end{frame}

\begin{frame}
  \frametitle{Charles \textsc{Hamblin} (1922 - 1985)}
  
%\begin{figure}
\begin{center}
  \includegraphics[height=0.9\textheight]{hamblin}
\end{center}
%\end{figure}
  
\end{frame}


\begin{frame}[fragile]
\begin{pythoncode}
In [55]: 9 / 2 + (-3) * 4 - (-5)
Out[55]: -2.5

In [56]: 9 / ((2 + (-3)) * (4 - (-5)))
Out[56]: -1.0
\end{pythoncode}
\end{frame}

\begin{frame}

{\small 
\begin{center}
\begin{tikzpicture}
[edge from parent fork down,
every node/.style={fill=blue!80!black,rounded corners},
edge from parent/.style={blue!30,thick,draw},level 1/.style={sibling distance=4.5cm},
level 2/.style={sibling distance=2.5cm},
level 3/.style={sibling distance=1.4cm}]
\node{$/$}
    child{node[fill=red!50!black]{$9$}}
    child{node{$\times$}
       child{node{$+$}
       child{node[fill=red!50!black]{$2$}}
       child{node{$-$}
            child{node[fill=red!50!black]{$3$}}}
       }
       child{node{$-$}
       child{node[fill=red!50!black]{$4$}}
       child{node{$-$}
            child{node[fill=red!50!black]{$5$}}}
       }
};
\end{tikzpicture}
\end{center}

}
\end{frame}



\begin{frame}

{\small 

\begin{center}
\begin{tikzpicture}
[edge from parent fork down,
every node/.style={fill=bleu!80!black,rounded corners},
edge from parent/.style={blue!30,thick,draw},level 1/.style={sibling distance=4.5cm},
level 2/.style={sibling distance=2.5cm},
level 3/.style={sibling distance=1.4cm}]
\node{$/$}
    child{node[fill=red!50!black]{$9$}}
    child{node{$\times$}
       child{node{$+$}
       child{node[fill=red!50!black]{$2$}}
       child{node{$\lnot$}
            child{node[fill=red!50!black]{$3$}}}
       }
       child{node{$-$}
       child{node[fill=red!50!black]{$4$}}
       child{node{$\lnot$}
            child{node[fill=red!50!black]{$5$}}}
       }
};
\end{tikzpicture}
\end{center}

}
\end{frame}

\begin{frame}

{\small 

\begin{center}
\begin{tikzpicture}
[edge from parent fork down,
every node/.style={fill=bleu!80!black,rounded corners},
edge from parent/.style={blue!30,thick,draw},level 1/.style={sibling distance=4.5cm},
level 2/.style={sibling distance=2.5cm},
level 3/.style={sibling distance=1.4cm}]
\node{$/$}
    child{node[fill=red!50!black]{$9$}}
    child{node{$\times$}
      child{node{$\lnot$}
        child{node[fill=red!50!black]{$1$}}
      }
      child{node[fill=red!50!black]{$9$}
      }
    };
\end{tikzpicture}
\end{center}
}
\end{frame}





\begin{frame}
  
{\small 

\begin{center}
\begin{tikzpicture}
[edge from parent fork down,
every node/.style={fill=bleu!80!black,rounded corners},
edge from parent/.style={blue!30,thick,draw},level 1/.style={sibling distance=4.5cm},
level 2/.style={sibling distance=2.5cm},
level 3/.style={sibling distance=1.4cm}]
\node{$/$}
    child{node[fill=red!50!black]{$9$}}
    child{node{$\lnot$}
      child{node[fill=red!50!black]{$9$}}
    };
\end{tikzpicture}
\end{center}
}

\end{frame}





\begin{frame}
  $$¬1$$
\end{frame}


\begin{frame}
  \begin{itemize}
  \item Pile
  \item Stack
  \item LIFO
  \item DEPS
  \item empiler / dépiler
  \item push / pop
  \end{itemize}
\end{frame}


\begin{frame}
\begin{figure}[ht]
  \centering
  \includegraphics[height=0.8\textheight]{trainKnuth}
  \caption{\label{fig:train}D.E. \textsc{Knuth}}
\end{figure}

\end{frame}


\begin{frame}
\begin{figure}[ht]
  \centering
  \includegraphics[width=\linewidth]{shuntingDijkstra}
  \caption{\label{fig:train}E. \textsc{Dijkstra}}
\end{figure}

\end{frame}




\begin{frame}
  \frametitle{Extrait de l'épreuve X-ENS (MP option SI et PC) 2015}

%\begin{figure}
\begin{center}
  \includegraphics[height=0.9\textheight]{CaptureX}
\end{center}
%\end{figure}
  
\end{frame}


\begin{frame}[fragile]
\frametitle{Premier contact avec la POO}

Les piles fabriquées avec des tuples:

\pause

\begin{pythoncode}
class pile0 () :

    p = ()

    def depile(self) :
        temp = self.p[-1]
        self.p = self.p[0:-1]
        return temp

    def empile(self, val) :
        self.p = self.p + (val,)

    def est_vide(self) :
        return self.p == ()
\end{pythoncode}

\end{frame}



\begin{frame}[fragile]
\frametitle{Second contact avec la POO}

Les piles fabriquées avec des listes:

\pause

\begin{pythoncode}
class pile1 () :

    p = []

    def dépile(self):
        return self.p.pop()
    
    def empile(self, val):
        self.p.append(val)
    
    def est_vide(self):
        return self.p == []
  
\end{pythoncode}

\end{frame}


\begin{frame}
  \frametitle{Pop de Python}
  
%\begin{figure}
\begin{center}
  \includegraphics[height=0.85\textheight]{pop}
\end{center}
%\end{figure}

\end{frame}


\begin{frame}[fragile]
  \frametitle{Pop de Python}
  

\begin{pythoncode}
In [1]: ?list.pop
Docstring:
L.pop([index]) -> item -- remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
Type:      method_descriptor  
\end{pythoncode}



\end{frame}



\begin{frame}[fragile]
  \frametitle{Contact plus musclé avec la POO}
  
\begin{pythoncode}
class Pile() :
    from copy import copy

    def __init__(self, sommet = None, suivant = None) :
        self.sommet = sommet
        self.suivant = suivant

    def est_vide(self) :
        return self.sommet == None

    def empile(self, val) :
        p = copy(self)
        self.suivant = p
        self.sommet = val
\end{pythoncode}



\end{frame}






\begin{frame}[fragile]
\begin{pythoncode}
    def depile(self) :
        assert not self.est_vide(), "Dépile pile vide"
        p = copy(self)
        top = p.sommet
        self.sommet = p.suivant.sommet
        self.suivant = p.suivant.suivant
        return top
\end{pythoncode}

  
\end{frame}


\begin{frame}[fragile]
\begin{pythoncode}
    def __repr__(self) :
        return str(self.sommet) + "|-"  
\end{pythoncode}

  
\end{frame}


\begin{frame}[fragile]
\begin{pythoncode}
In [123]: p = Pile()

In [124]: p.sommet

In [125]: p
Out[125]: None|-

In [126]: p.empile(1)

In [127]: p.empile(2)

In [128]: p
Out[128]: 2|-

In [129]: p.empile(3)

In [130]: p
Out[130]: 3|-  
\end{pythoncode}

  
\end{frame}


\begin{frame}[fragile]
\begin{pythoncode}
In [131]: p.depile()
Out[131]: 3

In [132]: p
Out[132]: 2|-

In [133]: p.depile()
Out[133]: 2

In [134]: p
Out[134]: 1|-

In [135]: p.depile()
Out[135]: 1

In [136]: p
Out[136]: None|-

In [137]: p.depile()
---------------------------------------------------------------------------
AssertionError: Dépile pile vide
\end{pythoncode}

  
\end{frame}





\begin{frame}\frametitle{Exemple}
\begin{tikzpicture}[>=stealth, shape aspect=.5]
\tikzset{
glob/.style={cylinder, shape border rotate=90,minimum width=1.5cm},%
cell/.style={glob,draw,thick,fill=blue,minimum height=1cm},%
base/.style={glob,cylinder,minimum height=1pt,fill=gray!50!black, cylinder end fill=gray!100},%
invisible/.style={glob,minimum height=1pt}%
}

\only<1,2>{\begin{scope}[xshift=-4cm]
\node [base] at (0,-0.5) {};
\node [invisible] (A) at (0,0) {};
\node at (0,-1) {pile vide};
\end{scope}}

\only<1,2,3>{\begin{scope}
\node[cell] (B)  at (0,0) {A};
\end{scope}}

\only<2,3,4>{\begin{scope}[xshift=4cm]
\node[cell] (C)  at (0,0) {A};
\node [cell] at (0,0.75) {B};
\end{scope}}

\only<3,4>{
\begin{scope}[xshift=8cm]
\node[cell] (D)  at (0,0) {A};
\end{scope}}

\only<4>{
\begin{scope}[xshift=12cm]
\node[cell] (E)  at (0,0) {A};
\node [cell] at (0,0.75) {A};
\end{scope}}

\only<1,2>{\path[draw,->,line width=5pt] (A) -- (B) node [midway,below] {\py{empile(A)}};}
\only<2,3>{\path[draw,->,line width=5pt] (B) -- (C) node [midway,below] {\py{empile(B)}};}
\only<3,4>{\path[draw,->,line width=5pt] (C) -- (D) node (xxx) [midway,below] {\py{dépile()}};}
\only<3,4>{\node (Y) [below= 0.7cm of xxx] {\py{return B}};
\path[draw,->,line width=3pt] (xxx) -- (Y);}
\only<4>{\path[draw,->,line width=5pt] (D) -- (E) node [midway,below] {\py{empile(A)}};}
\end{tikzpicture}

\end{frame}










\begin{frame}
  \frametitle{HP15c}

%\begin{figure}
\begin{center}
  \includegraphics[height=0.8\textheight]{hp15c}
\end{center}
%\end{figure}
  
\end{frame}



\begin{frame}[fragile]
  $$9/((2+\lnot 3)\times (4- \lnot 5))$$

\pause

\verb|9 2 3 NEG + 4 5 NEG - * /|

\pause


\begin{enumerate}
\item On lit l'expression de gauche à droite;
\item On empile les opérandes;
\item   Dès qu'on
lit un  opérateur, on l'applique  aux opérandes présents  sur la pile  selon son
arité;
\item On s'arrête quand on n'a plus rien à lire;
\item on renvoie le dernier élément présent dans la pile.
\end{enumerate}


\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
On entre \verb+9+ , \verb+2+ puis \verb+3+:

  \begin{pythoncode}
 Emacs Calculator Mode 
3:  9
2:  2
1:  3
.    
  \end{pythoncode}  
\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}

\verb+NEG+
  \begin{pythoncode}
Emacs Calculator Mode 
3:  9
2:  2
1:  -3    
  \end{pythoncode}  
\end{frame}






\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
 \verb|+|

  \begin{pythoncode}
 Emacs Calculator Mode 
2:  9
1:  -1
.
.    
  \end{pythoncode}  
\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}

\verb|4| puis \Enter
  \begin{pythoncode}
 Emacs Calculator Mode 
3:  9
2:  -1
1:  4
.    
  \end{pythoncode}  
\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
\verb|5| puis \Enter

  \begin{pythoncode}
 Emacs Calculator Mode 
4:  9
3:  -1
2:  4
1:  5    
  \end{pythoncode}  
\end{frame}






\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
\verb|NEG|

  \begin{pythoncode}
 Emacs Calculator Mode 
4:  9
3:  -1
2:  4
1:  -5    
  \end{pythoncode}  
\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
\verb|-|


  \begin{pythoncode}
 Emacs Calculator Mode 
3:  9
2:  -1
1:  9
.    
  \end{pythoncode}  
\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
\verb|*|

  \begin{pythoncode}
 Emacs Calculator Mode 
2:  9
1:  -9
.
.    
  \end{pythoncode}  
\end{frame}





\begin{frame}[fragile]
  \frametitle{Calculator Emacs}
\verb|/|

  \begin{pythoncode}
 Emacs Calculator Mode 
1: -1
.
.
.    
  \end{pythoncode}  
\end{frame}

\begin{frame}

\begin{itemize}
\item pas besoin de parenthèses, de règles d'associativité, de priorité;
\item on voit au sommet de la pile les résultats intermédiaires;
\item le calcul est directement implémentable sur machine.
\end{itemize}
  
\end{frame}




\begin{frame}[fragile]
  \frametitle{Notation polonaise}
  $$9/((2+\lnot 3)\times (4- \lnot 5))$$

\pause

\begin{center}

\og le \textit{rapport} entre
9   et   le   \textit{produit}   de  la   \textit{somme}   de   2   et
l'\textit{opposé}  de  3   et  la  \textit{différence}  de   4  et  de
l'\textit{opposé} de 5\fg{} 

\end{center}

\pause


\begin{center}
  \verb| / 9 * + 2 NEG 3 - 4 NEG 5|
\end{center}

\pause

Sur machine?

\end{frame}

\begin{frame}[fragile]
  \begin{exercice}
  
Décomposez le calcul \verb| / 9 * + 2  NEG 3 - 4 NEG 5|. Comment l'organiser sur
machine?  Comparez avec  la  NPI.  Expliquez alors  le  choix  fait par  Charles
\textsc{Hamblin} d'utiliser plutôt la NPI sur machine.  
  \end{exercice}
\end{frame}



\section{Pile d'exécution}

\begin{frame}

\paratitre{Lors de l'appel d'une fonction, que se passe-t-il ?}

Une bloc est créé pour la fonction, contenant :
\begin{itemize}
\item<+-> Les arguments de la fonction
\item<+-> Une place pour écrire la valeur de retour
\item<+-> L'\textit{adresse de retour}, i.e., une information disant ce qu'il faudra faire une fois la fonction terminée.
\item<+-> De la place pour les variables locales
\item<+-> \'Eventuellement d'autres informations
\end{itemize}
\end{frame}


\begin{frame}
\begin{tikzpicture}[>=stealth, shape aspect=.5]
\tikzset{glob/.style={cylinder, shape border rotate=90,minimum width=3.5cm,minimum height=1.5cm},cell/.style={glob,draw,thick,fill=blue},base/.style={glob,cylinder, cylinder uses custom fill, cylinder end fill=gray!100},invisible/.style={glob}}

\begin{scope}[xshift=-3.2cm]
\node[cell]  at (0,0) {Arguments};
\node [cell] at (0,0.9) {Valeur de retour};
\node [cell] at (0,0.9*2) {Adresse de retour};
\node [cell] at (0,0.9*3) {~~~~ Autre ~~~~};
\node [cell] at (0,0.9*4) {Variables locales};
\end{scope}

\node at (0,2) {{\huge $\mathbf{=}$}};

\begin{scope}[xshift=3.2cm]
\node[cell,minimum height=1.5cm]  at (0,1.5) {\begin{minipage}{3.3cm}\begin{center} Bloc \\ de la \\fonction\end{center} \end{minipage}};
\end{scope}

\end{tikzpicture}

\end{frame}

\begin{frame}

\paratitre{Lorsqu'une fonction appelle une autre fonction, que se passe-t-il ?}

Un bloc de la fonction appelé est créé ``au dessus'' du bloc de la fonction appelante. Ces blocs sont empilé dans la ``pile d'exécution''.

\end{frame}


\begin{frame}[fragile]
\paratitre{Comment sont gérés les appels de fonctions ?}

\only<article>{Considérons le code suivant.}

\begin{pythoncode}
def h(x) :
    return x + 1

def g(x) :
    return h(x) * 2
        
def f (x) :
    return g(x) + 1
\end{pythoncode}
\end{frame}
\only<article>{Que se passe-t-il lors de l'appel à \py{f(5)} ?}



\begin{frame}\frametitle{Exemple}
\begin{tikzpicture}[>=stealth, shape aspect=.5]
\tikzset{
glob/.style={cylinder, shape border rotate=90,minimum width=1.5cm},%
cell/.style={glob,draw,thick,fill=blue,minimum height=1cm},%
base/.style={glob,cylinder,thik,minimum height=1pt,fill=gray!50!black, cylinder end fill=gray!100},%
invisible/.style={glob,minimum height=1pt}%
}
\only<1,2>{\begin{scope}[xshift=-4cm]
\node [base] at (0,-0.5) {};
\node [invisible] (A) at (0,0) {};
\node at (0,-1) {pile vide};
\end{scope}}

\only<1,2,3>{\begin{scope}
\node[cell] (B)  at (0,0) {\py{f}};
\end{scope}}

\only<2,3>{\begin{scope}[xshift=4cm]
\node[cell] (C)  at (0,0) {\py{f}};
\node [cell] at (0,0.75) {\py{g}};
\end{scope}}

\only<3>{
\begin{scope}[xshift=8cm]
\node[cell] (D)  at (0,0) {\py{f}};
\node [cell] at (0,0.75) {\py{g}};
\node [cell] at (0,0.75*2) {\py{h}};
\end{scope}}
%
%\only<4>{
%\begin{scope}[xshift=12cm]
%\node[cell] (E)  at (0,0) {A};
%\node [cell] at (0,0.75) {A};
%\end{scope}}

\only<1,2>{\path[draw,->,line width=5pt] (A) -- (B) node [midway,below] {appel de \py{f}};}
\only<2,3>{\path[draw,->,line width=5pt] (B) -- (C) node [midway,below] {appel de \py{g}};}
\only<3>{\path[draw,->,line width=5pt] (C) -- (D) node (xxx) [midway,below] {appel de \py{h}};}
%\only<3,4>{\node (Y) [below= 0.7cm of xxx] {\py{return B}};
%\path[draw,->,line width=3pt] (xxx) -- (Y);}
%\only<4>{\path[draw,->,line width=5pt] (D) -- (E) node [midway,below] {\py{empile(A)}};}
\end{tikzpicture}

\end{frame}




\begin{frame}\frametitle{Exemple}
\begin{tikzpicture}[>=stealth, shape aspect=.5]
\tikzset{
glob/.style={cylinder, shape border rotate=90,minimum width=1.5cm},%
cell/.style={glob,draw,thick,fill=blue,minimum height=1cm},%
base/.style={glob,cylinder,thik,minimum height=1pt,fill=gray!50!black, cylinder end fill=gray!100},%
invisible/.style={glob,minimum height=1pt}%
}

\only<1,2>{\begin{scope}[xshift=-4cm]
\node[cell] (D)  at (0,0) {\py{f}};
\node [cell] at (0,0.75) {\py{g}};
\node [cell] at (0,0.75*2) {\py{h}};
\end{scope}}

\only<1,2,3>{\begin{scope}


\node[cell] (C)  at (0,0) {\py{f}};
\node [cell] at (0,0.75) {\py{g}};
\end{scope}}

\only<2,3>{\begin{scope}[xshift=4cm]
\node[cell] (B)  at (0,0) {\py{f}};
\end{scope}}

\only<3>{
\begin{scope}[xshift=8cm]
\node [base] at (0,-0.5) {};
\node [invisible] (A) at (0,0) {};
\node at (0,-1) {pile vide};
\end{scope}}
%
%\only<4>{
%\begin{scope}[xshift=12cm]
%\node[cell] (E)  at (0,0) {A};
%\node [cell] at (0,0.75) {A};
%\end{scope}}

\only<3>{\path[draw,->,line width=5pt] (B) --(A) node [midway,below] {retour de \py{f}};}
\only<2,3>{\path[draw,->,line width=5pt] (C) -- (B) node [midway,below] {retour de \py{g}};}
\only<1,2>{\path[draw,->,line width=5pt] (D) -- (C) node (xxx) [midway,below] {retour de \py{h}};}
%\only<3,4>{\node (Y) [below= 0.7cm of xxx] {\py{return B}};
%\path[draw,->,line width=3pt] (xxx) -- (Y);}
%\only<4>{\path[draw,->,line width=5pt] (D) -- (E) node [midway,below] {\py{empile(A)}};}
\end{tikzpicture}

\end{frame}

\only<article>{Un autre exemple :}

\begin{frame}[fragile]
\begin{pythoncode}
def h(x) :
    return x + 1

def g(x) :
    return h(x) * 2
        
def i(x) :
    a = g(x)
    b = h(x)
    return a + b
\end{pythoncode}
\end{frame}


\begin{frame}\frametitle{Exemple}
\begin{tikzpicture}[>=stealth, shape aspect=.5]

\tikzset{
glob/.style={cylinder, shape border rotate=90,minimum width=1.5cm},%
cell/.style={glob,draw,thick,fill=blue,minimum height=1cm},%
base/.style={glob,cylinder,thik,minimum height=1pt,fill=gray!50!black, cylinder end fill=gray!100},%
invisible/.style={glob,minimum height=1pt}%
}

\only<1,2>{\begin{scope}[xshift=-4cm]
\node [base] at (0,-0.5) {};
\node [invisible] (A) at (0,0) {};
\node at (0,-1) {pile vide};
\end{scope}}

\only<1,2,3>{\begin{scope}
\node[cell] (B)  at (0,0) {\py{i}};
\end{scope}}

\only<2,3>{\begin{scope}[xshift=4cm]
\node[cell] (C)  at (0,0) {\py{i}};
\node [cell] at (0,0.75) {\py{g}};
\end{scope}}

\only<3>{
\begin{scope}[xshift=8cm]
\node[cell] (D)  at (0,0) {\py{i}};
\node [cell] at (0,0.75) {\py{g}};
\node [cell] at (0,0.75*2) {\py{h}};
\end{scope}}
%
%\only<4>{
%\begin{scope}[xshift=12cm]
%\node[cell] (E)  at (0,0) {A};
%\node [cell] at (0,0.75) {A};
%\end{scope}}

\only<1,2>{\path[draw,->,line width=5pt] (A) -- (B) node [midway,below] {appel de \py{i}};}
\only<2,3>{\path[draw,->,line width=5pt] (B) -- (C) node [midway,below] {appel de \py{g}};}
\only<3>{\path[draw,->,line width=5pt] (C) -- (D) node (xxx) [midway,below] {appel de \py{h}};}
%\only<3,4>{\node (Y) [below= 0.7cm of xxx] {\py{return B}};
%\path[draw,->,line width=3pt] (xxx) -- (Y);}
%\only<4>{\path[draw,->,line width=5pt] (D) -- (E) node [midway,below] {\py{empile(A)}};}
\end{tikzpicture}

\end{frame}




\begin{frame}\frametitle{Exemple}
\begin{tikzpicture}[>=stealth, shape aspect=.5]

\tikzset{
glob/.style={cylinder, shape border rotate=90,minimum width=1.5cm},%
cell/.style={glob,draw,thick,fill=blue,minimum height=1cm},%
base/.style={glob,cylinder,thik,minimum height=1pt,fill=gray!50!black, cylinder end fill=gray!100},%
invisible/.style={glob,minimum height=1pt}%
}

\only<1,2>{\begin{scope}[xshift=-4cm]
\node[cell] (D)  at (0,0) {\py{i}};
\node [cell] at (0,0.75) {\py{g}};
\node [cell] at (0,0.75*2) {\py{h}};
\end{scope}}

\only<1,2,3>{\begin{scope}


\node[cell] (C)  at (0,0) {\py{i}};
\node [cell] at (0,0.75) {\py{g}};
\end{scope}}

\only<2,3>{\begin{scope}[xshift=4cm]
\node[cell] (B)  at (0,0) {\py{i}};
\end{scope}}

\only<3>{
\begin{scope}[xshift=8cm]
\node[cell] (A)  at (0,0) {\py{i}};
\node [cell] at (0,0.75) {\py{h}};
\end{scope}}
%
%\only<4>{
%\begin{scope}[xshift=12cm]
%\node[cell] (E)  at (0,0) {A};
%\node [cell] at (0,0.75) {A};
%\end{scope}}

\only<3>{\path[draw,->,line width=5pt] (B) --(A) node [midway,below] {appel de \py{h}};}
\only<2,3>{\path[draw,->,line width=5pt] (C) -- (B) node [midway,below] {retour de \py{g}};}
\only<1,2>{\path[draw,->,line width=5pt] (D) -- (C) node (xxx) [midway,below] {retour de \py{h}};}
%\only<3,4>{\node (Y) [below= 0.7cm of xxx] {\py{return B}};
%\path[draw,->,line width=3pt] (xxx) -- (Y);}
%\only<4>{\path[draw,->,line width=5pt] (D) -- (E) node [midway,below] {\py{empile(A)}};}
\end{tikzpicture}

\end{frame}


\begin{frame}<2->\frametitle{Exemple}
\begin{tikzpicture}[>=stealth, shape aspect=.5]

\tikzset{
glob/.style={cylinder, shape border rotate=90,minimum width=1.5cm},%
cell/.style={glob,draw,thick,fill=blue,minimum height=1cm},%
base/.style={glob,cylinder,thik,minimum height=1pt,fill=gray!50!black, cylinder end fill=gray!100},%
invisible/.style={glob,minimum height=1pt}%
}
%\only<1,2>{\begin{scope}[xshift=-4cm]
%\node[cell] (D)  at (0,0) {\py{f}};
%\node [cell] at (0,0.75) {\py{g}};
%\node [cell] at (0,0.75*2) {\py{h}};
%\end{scope}}

\only<1,2,3>{\begin{scope}


\node[cell] (C)  at (0,0) {\py{i}};
\node [cell] at (0,0.75) {\py{h}};
\end{scope}}

\only<2,3>{\begin{scope}[xshift=4cm]
\node[cell] (B)  at (0,0) {\py{i}};
\end{scope}}

\only<3>{
\begin{scope}[xshift=8cm]
\node [base] at (0,-0.5) {};
\node [invisible] (A) at (0,0) {};
\node at (0,-1) {pile vide};
\end{scope}}
%
%\only<4>{
%\begin{scope}[xshift=12cm]
%\node[cell] (E)  at (0,0) {A};
%\node [cell] at (0,0.75) {A};
%\end{scope}}

\only<3>{\path[draw,->,line width=5pt] (B) --(A) node [midway,below] {retour de \py{i}};}
\only<2,3>{\path[draw,->,line width=5pt] (C) -- (B) node [midway,below] {retour de \py{h}};}
%\only<1,2>{\path[draw,->,line width=5pt] (D) -- (C) node (xxx) [midway,below] {retour de \py{h}};}
%\only<3,4>{\node (Y) [below= 0.7cm of xxx] {\py{return B}};
%\path[draw,->,line width=3pt] (xxx) -- (Y);}
%\only<4>{\path[draw,->,line width=5pt] (D) -- (E) node [midway,below] {\py{empile(A)}};}
\end{tikzpicture}

\end{frame}


\begin{frame}
  Merci à Jean-Loup Carré pour ces beaux dessins de piles...
\end{frame}

\end{document}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
