\documentclass[12pt]{article} % % Doug Nychka's LaTeX template (8/13/2004). To create a pdf file from this %use pdflatex % % if you read one more comment read the one that starts with *********** % % \nofiles % Suppress all those pesky files! % include some color support (see examples below) \usepackage[usenames,dvipsnames]{color} % % set background color \definecolor{Fcolor}{rgb}{.1,.1,.1} % A cool manila \definecolor{Pcolor}{rgb}{1,1,1} % A cool manila \pagecolor{Pcolor} % see the Tex files associated with dvipsnames % for some predefined colors. % % this little style file allows you to % step through a page adding items % \usepackage{isolatin1} \usepackage{pause} % % include a graphics package for importing figures % \usepackage{graphicx} % % this nice package supports pdf, png, and jpeg in pdflatex %( but just eps for latex) % png and jpg formats for images are particularly efficient. % In R use the pdf/png function to create a pdf/png graphics file. % If you have a ps file in UNIX use convert foo.ps foo.pdf % to make it into a pdf version % % If the postscript file has too much white space around it % use ps2epsi foo.ps ; epstopdf foo.eps foo.pdf to shrink wrap the figure % % or use the utility xv to crop images manually. % % %******* The magic of pdflatex, % These options give information to the acrobat viewer for displaying. % Use % pdflatex example.tex % to create example.pdf for viewing ( e.g. acroread example.pdf) % if you comment out the next two lines you can just use latex to make the % usual kind of dvi or postscript output. But you will have to use % postscript figures instead of pdf ones. % \RequirePackage[pdftex,pdfpagemode=none, pdftoolbar=true, pdffitwindow=true,pdfcenterwindow=true]{hyperref} % % change these to suit! Margins assume an inch as default % \setlength{\paperheight}{7in} \setlength{\paperwidth}{9in} \setlength{\textheight}{6.75in} \setlength{\textwidth}{7.5in} \setlength{\evensidemargin}{-.75in} \setlength{\oddsidemargin}{-.75in} \setlength{\topmargin}{-.75in} \setlength{\parskip}{.125in} \setlength{\parindent}{0in} % % % set background color \definecolor{Pcolor}{rgb}{1,1,1} % A rosy manila \pagecolor{Pcolor} % Define heading color. \definecolor{Hcolor}{rgb}{.3,.3,.3} % my heading color % % these are my basic page headings % note how the color is set % \def\mytitle#1{{\color{Hcolor}{\it \LARGE #1}\\ }} \def\MYTITLE#1{{\color{Hcolor}{\huge #1}\\ \rule[.15in]{\textwidth}{.03in} }} \def\myTITLE#1{{\color{Hcolor}{\huge #1}\\}} % just to make the math work, everyone does this differently ... \newcommand{\BLD}[1]{\mbox{\boldmath $#1$}} % low tech way to start a new "slide" and add a background image % This has been tuned to the aspect paper sizes declared above. \newcommand{\emptyBS}{ \newpage \vspace*{-1in} \hspace*{-.5in} %\includegraphics[height=\paperheight, % width=\paperwidth]{dia0231_med.jpg} % old fire %\vspace*{-\paperheight} \vspace*{.5in} %\hspace*{-\paperwidth} } \newcommand{\BS}{ \newpage \vspace*{-1in} % \hspace*{-.5in} {\begin{center} Vom {\tt for} zum {\tt while} - \href{http://30hd.org/euclid/}{http://30hd.org/euclid/} \end{center}} %\includegraphics[height=\paperheight, % width=\paperwidth]{dia0230_back.jpg} % old fire %\vspace*{-\paperheight} \vspace*{.5in} %\hspace*{-\paperwidth} } % uncomment this version for just a new page and no background image. % note that you still get a background color from setting \pagecolor above %\newcommand{\BS}{ \newpage} \begin{document} \hypertarget{start}{} %%%%%%%%%%% {\color{Black} %begin default text color %{\color{White} %begin default text color {\LARGE % fault is LARGE size font { \sf % default face is sans serif %%%%%%%%%%%% %\vspace*{-1in} %\hspace*{-.5in} %\includegraphics[height=\paperheight, % width=\paperwidth]{dia0230_back.jpg} % old fire %\vspace*{-\paperheight} %\vspace*{.5in} %\hspace*{-\paperwidth} \BS \MYTITLE{Schleifen in Javascript: Vorsicht vor Bedingungen} {\tt for ({\bf $<$Initialisation$>$}; {\bf $<$Bedingung$>$}; {\bf $<$Iterationsschritt$>$})\\ \{ {\small Alexander \"Olzant\\} \BS \MYTITLE{Anatomie einer {\tt for}-Schleife} {\tt for ({\bf $<$Initialisation$>$}; {\bf $<$Bedingung$>$}; {\bf $<$Iterationsschritt$>$})\\ \{ \hspace{1cm}{\bf $<$Schleifenk\"orper (Body)$>$} \} } %%%%%%%%%%%% %%%%%%%%%%%%%%% \vspace*{.5in} % adjust this to makes things fit nicely %\includegraphics[height=1.5in]{dia0231_med.jpg} %\hfill %\includegraphics[height=1in]{dia0231_med.jpg} %\\{\it \normalsize %Supported by the National Science Foundation DMS %} \BS \MYTITLE{Vereinfachungen: Initialisierung vor der Schleife} {\tt for ({\bf $<$Initialisation$>$}; {\bf $<$Bedingung$>$}; {\bf $<$Iteration$>$}) \{ \}} \pause Initialisation vorziehen \pause {\bf $<$Initialisation$>$} {\tt for (; {\bf $<$Bedingung$>$}; {\bf $<$Iteration$>$}) \{ \}} \BS \MYTITLE{Vereinfachungen: Inkrement in der Schleife} {\tt for ({\bf $<$Initialisation$>$}; {\bf $<$Bedingung$>$}; {\bf $<$Iterationsschritt$>$}) \{ \}} \pause Initialisation und Iterationsschritt (Inkrement/Variablenupdate) verschieben \pause {\bf $<$Initialisation$>$} {\tt for (; {\bf $<$Bedingung$>$}; )} \{ \hspace{1cm}{\bf $<$Iterationsschritt$>$} \} \BS \MYTITLE{Statt dessen: while} {\tt for ({\bf $<$Initialisation$>$}; {\bf $<$Bedingung$>$}; {\bf $<$Iterationsschritt$>$})} Initialisation und Iterationsschritt (Inkrement/Variablenupdate) verschieben: {\bf $<$Initialisation$>$} {\tt while ({\bf $<$Bedingung$>$})} \{ \hspace{1cm}{\bf $<$Iterationsschritt$>$} \} \BS \MYTITLE{Statt dessen: while} {\tt for ({\bf $<$Initialisation$>$}; {\bf $<$Bedingung$>$}; {\bf $<$Iterationsschritt$>$})} Initialisation und Iterationsschritt (Inkrement/Variablenupdate) verschieben Initialisation und Inkrement sind optional \dots {\tt while ({\bf $<$Bedingung$>$})} \{ \dots \} \BS \MYTITLE{Beispiel} \begin{verbatim} for (i = 0; i < 10; i ++) { quadrat = i * i; } \end{verbatim} \BS \MYTITLE{Beispiel} \begin{verbatim} var i = 0; for (; i < 10; i++) { quadrat = i * i; } \end{verbatim} \BS \MYTITLE{Beispiel} \begin{verbatim} var i = 0; for (; i < 10;) { quadrat = i * i; i += 1; } \end{verbatim} \BS \MYTITLE{Beispiel} \begin{verbatim} var i = 0; while (i < 10) { quadrat = i * i; i += 1; } \end{verbatim} \emptyBS %\MYTITLE{Beispiel 2: Quadratwurzel} {\large - Beispiel 2: Quadratwurzel} \begin{verbatim} var i = 0; var zahl = 10; var quadratwurzel = i/2; var differenz; differenz = (quadratwurzel * quadratwurzel) - zahl; \end{verbatim} {\bf while (Math.abs(differenz) $>$ 1) \{} \begin{verbatim} if (differenz != 0) { quadratwurzel -= (quadratwurzel - zahl/quadratwurzel)/2; } quadratwurzel = zahl/quadratwurzel; differenz = ((quadratwurzel * quadratwurzel) - zahl); } \end{verbatim} \href{http://30hd.org/euclid/quadratwurzel.html}{http://30hd.org/euclid/quadratwurzel.html} \BS \MYTITLE{Beispiel: ggt/Subtraktion} \begin{enumerate} \item $a = 9690, b = 3825 \Rightarrow a - b = 5865$ \pause \item $a = 5865, b = 3825 \Rightarrow a - b = 2040$ \pause \item $a = 2040, b = 3825$ ... tauschen \pause \item $a = 3825, b = 2040 \Rightarrow a - b = 1785$ \pause \item $a = 1785, b = 2048$ ... tauschen \pause \item $a = 2040, b = 1785 \Rightarrow a - b = 255$ \pause \item $a = 255, b = 1785$ ... tauschen \pause \item $a = 1785, {\bf b = 255}$ teilbar, $r = 0$ \end{enumerate} \pause {\tt ggt(9690,3825) == 255} \BS \MYTITLE{\"Uberlegung zur mehrmaligen Subtraktion} %\includegraphics[width=\textwidth]{ggts.eps} \includegraphics[width=\textwidth]{ggts.jpg} \% (Modulo): Divisions{\bf rest} \BS \MYTITLE{Beispiel: ggt/Modulo} \begin{enumerate} \item $a = 9690, b = 3825 \Rightarrow a \% b = r = 2040$ \pause \item $a = 2040, b = 3825$ ... tauschen \pause \item $a = 3825, b = 2040 \Rightarrow = r = 1785$ \pause \item $a = 1785, b = 2048$ ... tauschen \pause \item $a = 2040, b = 1785 \Rightarrow r = 255$ \pause \item $a = 255, b = 1785$ ... tauschen \pause \item $a = 1785, {\bf b = 255}$ teilbar, $r = 0$ \end{enumerate} {\tt ggt(9690,3825) == 255} \BS \MYTITLE{graphische \"Uberlegung} %\includegraphics[width=\textwidth]{ggts.eps} \includegraphics[width=\textwidth]{ggts1.jpg} \BS \MYTITLE{graphische \"Uberlegung} %\includegraphics[width=\textwidth]{ggts.eps} \includegraphics[width=\textwidth]{ggts2.jpg} %\BS %\MYTITLE{graphische \"Uberlegung} %\includegraphics[width=\textwidth]{ggts.eps} \includegraphics[width=\textwidth]{ggts3.jpg} \BS \MYTITLE{Schreibweise} \begin{tabular}[l]{l@{\hspace{1cm}}l} $b|a$ & b teilt a ({\tt a \% b == 0}) \\ $ggt(a,b)$ & gr\"osster gemeinsamer Teiler \end{tabular} %% example of target from a link %% use extra arrows in veiwer to return }% end LARGE font block } % end of bold face block } % end default text color block \end{document}