% (c) Olivier Pirson --- DragonSoft --- OPiTeXtes/petitPapier/polyturtle/polyturtle.tex
\documentclass[a4paper,ps2pdf]{article}

% Débuté le dimanche 28 janvier 2007
\date{dimanche $10$ juillet $2011$}

\title{\huge\textbf{polyturtle}}

\def\EMAILOPi{olivier\_pirson\_opi@yahoo.fr}
\def\INTERNETDS{www.opimedia.be/DS/}
\def\INTERNETOPi{www.opimedia.be/}

\author{%
  \mailShow[polyturtle]{\EMAILOPi}\\
  \hrefShow{http://\INTERNETOPi}}



\usepackage{amssymb}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{eulervm}
\usepackage[english,francais]{babel}

\usepackage[margin=1.5cm,top=1.2cm,bottom=1.8cm]{geometry}

\usepackage{color}
\usepackage{path}
\usepackage[baseurl=http://\INTERNETOPi,bookmarks,bookmarksnumbered,colorlinks,%
  hyperindex,pagebackref,urlcolor=blue]{hyperref}

\usepackage{graphicx}

\usepackage{listings}
\lstset{extendedchars=true,frame=leftline,showstringspaces=false,basicstyle=\small,%
  commentstyle={\color{blue}\itshape},morekeywords={False},keywordstyle={\color{red}\bfseries},%
  stringstyle={\color{magenta}\itshape}}



\hyphenpenalty=10000
\sloppy

\definecolor{Gray}{rgb}{.4,.4,.4}
\definecolor{Mail}{rgb}{0,.5,0}

\hypersetup{citecolor=Gray}
\hypersetup{linkcolor=Gray}

\hypersetup{pdfauthor={Olivier Pirson <\EMAILOPi>}}

\hypersetup{pdftitle={polyturtle},
  pdfsubject={Utilisation de la tortue graphique en Python, avec une version en PostScript.
    Et un exemple Graphviz à partir de Python.}}

\hypersetup{pdfkeywords={tortue, Python, PostScript, PS, Graphviz, problème sigma impair}}



%%%%%%%%%%%%%
% Commandes %
%%%%%%%%%%%%%
% Hyperlien affichant l'URL
\DeclareRobustCommand*{\hrefShow}[1]{% URL
  \href{#1}{\path|#1|}}

\makeatletter
% Hyperlien d'une adresse e-mail
\DeclareRobustCommand*{\mailShow}[2][\@empty]{% [subject], mail
  \ifx\@empty#1\relax
    \href{mailto:#2}{\color{Mail}\path|#2|}%
  \else
    \href{mailto:#2?subject=[#1]}{\color{Mail}\path|#2|}%
  \fi}
\makeatother



%%%%%%%%%%%%%%
% Opérateurs %
%%%%%%%%%%%%%%
\makeatletter
% Ensemble des naturels
% * : Ensemble des naturels strictement positifs
\DeclareRobustCommand*{\naturals}{\@ifstar{\mathbb{N}_{\ast}}{\mathbb{N}}}
\makeatother

% Opérateur sigma_impair
\DeclareRobustCommand{\sigmao}{\sigma_{\mathrm{impair}}}



\begin{document}%
%
\maketitle
\thispagestyle{empty}



\begin{abstract}
  Utilisation de la tortue graphique en Python,
  avec une version en PostScript.
  Suivi d'un petit exemple d'utilisation de Graphviz à partir de Python.
  (Les différents fichiers utilisés sont disponibles en ligne :
  \hrefShow{http://\INTERNETDS petits\_papiers/}\,.
  Ces programmes sont compatibles avec Python $3$.)
\end{abstract}



\section{La tortue graphique en Python}
\noindent
\enlargethispage{2\baselineskip}%
Le module \textbf{standard}
\href{http://docs.python.org/library/turtle.html#module-turtle}{\texttt{turtle}}
\footnote{\hrefShow{http://docs.python.org/library/turtle.html\#module-turtle}}
implémente en
\href{http://www.python.org/}{Python}
\footnote{\hrefShow{http://www.python.org/}}
la tortue graphique jadis popularisée par le langage Logo.
(Un module \textbf{optionnel}
\href{http://xturtle.rg16.at/}{\texttt{xturtle}}
\footnote{\hrefShow{http://xturtle.rg16.at/}}
offre un peu plus de contrôle sur la tortue.)\\
Le livre en ligne
\foreignlanguage{english}{\href{http://www.openbookproject.net/thinkcs/}%
  {\textsl{How to Think Like a Computer Scientist: Learning with Python}}}
\footnote{\hrefShow{http://www.openbookproject.net/thinkcs/}}
est une bonne initiation.

\medskip
\lstinputlisting[language=Python,lastline=2]{polyturtle.py}
\lstinputlisting[language=Python,firstline=6]{polyturtle.py}

\medskip
\noindent
Ce qui donne ceci :\\[-2ex]
\includegraphics{polyturtle.eps}

\medskip
\noindent
En fait cette image a été générée (pour l'inclure dans ce document)
par le programme PostScript suivant\dots



\section{Version PostScript}
\noindent
Un programme en PostScript
\footnote{Interpréteur PostScript : GhostScript, \hrefShow{http://www.ghostscript.com/}}
qui produit les mêmes dessins que le programme Python qui précède.

\medskip
\lstinputlisting[language=TeX,lastline=3]{polyturtle.eps}
\lstinputlisting[language=TeX,firstline=6]{polyturtle.eps}



\section{Petit exemple d'utilisation de Graphviz à partir de Python}
\noindent
L'ensemble des logiciels \href{http://www.graphviz.org/}{\texttt{dot}}
\footnote{\hrefShow{http://www.graphviz.org/}}
permet de facilement réaliser des graphes tels que celui-ci :

\medskip
\noindent
\begin{picture}(0,0)(0,0)
  \put(20,-710){\includegraphics{sigmaodd.eps}}
\end{picture}

\newpage
\noindent
Ce graphe a été généré à partir du fichier \texttt{.dot} suivant :
\lstinputlisting[lastline=15]{sigmaodd.dot}
\dots
\lstinputlisting[firstline=59]{sigmaodd.dot}

\bigskip
\noindent
Qui a lui-même été généré à partir du petit programme Python :
\lstinputlisting[language=Python,lastline=2]{sigmaodd.py}
\lstinputlisting[language=Python,firstline=6]{sigmaodd.py}

\bigskip
\noindent
Le graphe représente les parcours
$n, \sigmao(n), \sigmao^2(n), \sigmao^3(n)\dots$
pour les $n$ allant de $1$ à $50$.

\medskip
\noindent
Je \textbf{conjecture}
\begin{tabular}[t]{@{}r@{\ }l@{}}%
  que & $\forall n \in \naturals*, \exists k \in \naturals :\ \sigmao^k(n) = 1$\\
  et & $\forall n \in \naturals* :\ \sigmao^n(n) = 1$\\
\end{tabular}\hfil
(cf. le
\href{http://\INTERNETOPi 3nP1/index.htm#problemeSigmaImpair}{problème $\sigmao$})
%
\thispagestyle{empty}



\bigskip
\addcontentsline{toc}{section}{\contentsname}%
\tableofcontents
%
\end{document}