summaryrefslogtreecommitdiff
path: root/aied2018/presentation/patterns.tex
diff options
context:
space:
mode:
Diffstat (limited to 'aied2018/presentation/patterns.tex')
-rw-r--r--aied2018/presentation/patterns.tex15
1 files changed, 12 insertions, 3 deletions
diff --git a/aied2018/presentation/patterns.tex b/aied2018/presentation/patterns.tex
index b581157..8c701e9 100644
--- a/aied2018/presentation/patterns.tex
+++ b/aied2018/presentation/patterns.tex
@@ -37,6 +37,15 @@ for tree={
Such patterns can represent a program’s control structure, relationships between variables, etc. The red pattern below matches nested \code{for} and \code{if} statements, while the blue pattern relates two occurrences of the variable~\code{n}.
+\begin{textblock}{0}(4,0.5)
+\begin{Verbatim}
+\textbf{\red{def}} divisors(\textbf{\blue{n}}):
+ \textbf{\red{for}} d \textbf{in} range(1,\textbf{\blue{n}}):
+ \textbf{\red{if}} n % d == 0:
+ \textbf{print}(d)
+\end{Verbatim}
+\end{textblock}
+
\begin{figure}[htb]
\centering
\vspace{0.8cm}
@@ -49,8 +58,8 @@ for tree={
[name, name=name1 [divisors, name=divisors, font=\bfseries\sffamily]]
[args, name=args1
[Var, name=args1-1, draw,rectangle,blue,line width=2pt [n, font=\bfseries\sffamily, l=0.7cm]]]
- [body, name=body1, before computing xy={s=10cm}
- [For, name=for, l=5cm, draw,rectangle,red,line width=2pt
+ [body, name=body1, before computing xy={s=6cm}
+ [For, name=for, l=7cm, draw,rectangle,red,line width=2pt
[target
[Var, l=0.9cm [d, font=\bfseries\sffamily, l=0.7cm]]]
[iter, name=iter
@@ -72,7 +81,7 @@ for tree={
[func [print, font=\bfseries\sffamily, l=0.7cm]]
[args [Var, l=0.7cm [d, font=\bfseries\sffamily, l=0.6cm]]]]]]]]]]
% first pattern
- \path[-{Latex[length=5mm,width=2mm]},thick,relative,red] (def) edge[line width=2pt,transform canvas={xshift=1.1mm,yshift=1.5mm}] (body1);
+ \path[-{Latex[length=5mm,width=2mm]},thick,relative,red] (def) edge[line width=2pt,transform canvas={xshift=3.3mm,yshift=0mm}] (body1);
\path[-{Latex[length=5mm,width=2mm]},thick,relative,red] (body1) edge[line width=2pt,transform canvas={xshift=2mm}] (for);
\path[-{Latex[length=5mm,width=2mm]},thick,relative,red] (for) edge[line width=2pt,transform canvas={xshift=1.1mm,yshift=1.5mm}] (body2);
\path[-{Latex[length=5mm,width=2mm]},thick,relative,red] (body2) edge[line width=2pt,transform canvas={xshift=2mm}] (if);