--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/fun/add.fun Wed Dec 02 16:03:57 2020 +0000
@@ -0,0 +1,10 @@
+
+
+def add(x, y) =
+ if x == 0 then y else 1 + (add(x - 1, y));
+
+def addT(x, y) =
+ if x == 0 then y else addT(x - 1, y + 1);
+
+(write(add(1000, 1000)); addT(100000,100000))
+
--- a/progs/fun/fact.fun Tue Dec 01 05:41:12 2020 +0000
+++ b/progs/fun/fact.fun Wed Dec 02 16:03:57 2020 +0000
@@ -9,7 +9,7 @@
//fact(10)
//facTi(10)
-write(facTi(6))
+write(fact(6)); facTi(6)
// a simple factorial program
// (including a tail recursive version)
--- a/progs/fun/fun.sc Tue Dec 01 05:41:12 2020 +0000
+++ b/progs/fun/fun.sc Wed Dec 02 16:03:57 2020 +0000
@@ -50,13 +50,12 @@
.super java/lang/Object
.method public static write(I)V
- .limit locals 5
- .limit stack 5
- iload 0
- getstatic java/lang/System/out Ljava/io/PrintStream;
- swap
- invokevirtual java/io/PrintStream/println(I)V
- return
+ .limit locals 1
+ .limit stack 2
+ getstatic java/lang/System/out Ljava/io/PrintStream;
+ iload 0
+ invokevirtual java/io/PrintStream/println(I)V
+ return
.end method
"""
@@ -142,7 +141,7 @@
val env = args.zipWithIndex.toMap
val is = "I" * args.length
m".method public static $name($is)I" ++
- m".limit locals ${args.length.toString}" ++
+ m".limit locals ${args.length}" ++
m".limit stack ${1 + max_stack_exp(a)}" ++
l"${name}_Start" ++
compile_exp(a, env) ++
Binary file slides/slides08.pdf has changed
--- a/slides/slides08.tex Tue Dec 01 05:41:12 2020 +0000
+++ b/slides/slides08.tex Wed Dec 02 16:03:57 2020 +0000
@@ -561,9 +561,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
-\frametitle{Factorial}
+\frametitle{\mbox{}\hspace{5cm}Factorial}
-\begin{textblock}{7}(1,1.8)\footnotesize
+\begin{textblock}{7}(0,1.0)\footnotesize
\begin{minipage}{6cm}
\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
.method public static facT(II)I