|
@@ -62,7 +62,7 @@ showstringspaces=false
|
|
\lstset{%
|
|
\lstset{%
|
|
language=Python,
|
|
language=Python,
|
|
basicstyle=\ttfamily\small,
|
|
basicstyle=\ttfamily\small,
|
|
-morekeywords={match,case,bool,int,let,begin,if,else},
|
|
|
|
|
|
+morekeywords={match,case,bool,int,let,begin,if,else,closure},
|
|
deletekeywords={},
|
|
deletekeywords={},
|
|
escapechar=|,
|
|
escapechar=|,
|
|
columns=flexible,
|
|
columns=flexible,
|
|
@@ -17773,7 +17773,7 @@ $\Rightarrow$
|
|
{\if\edition\pythonEd\pythonColor
|
|
{\if\edition\pythonEd\pythonColor
|
|
% free_var.py
|
|
% free_var.py
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
-def f(x : int) -> Callable[[int], int]:
|
|
|
|
|
|
+def f(x: int) -> Callable[[int],int]:
|
|
y = 4
|
|
y = 4
|
|
return lambda z: x + y + z
|
|
return lambda z: x + y + z
|
|
|
|
|
|
@@ -17783,24 +17783,24 @@ print(g(11) + h(15))
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
$\Rightarrow$
|
|
$\Rightarrow$
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
-def lambda_0(fvs_1 : tuple[bot,int,tuple[int]], z : int) -> int:
|
|
|
|
|
|
+def lambda_0(fvs_1: tuple[bot,int,tuple[int]], z: int) -> int:
|
|
x = fvs_1[1]
|
|
x = fvs_1[1]
|
|
y = fvs_1[2]
|
|
y = fvs_1[2]
|
|
return (x + y[0] + z)
|
|
return (x + y[0] + z)
|
|
|
|
|
|
-def f(fvs_2 : bot, x : int) -> tuple[Callable[[tuple[],int], int]]:
|
|
|
|
|
|
+def f(fvs_2: tuple[bot], x: int) -> tuple[Callable[[tuple[],int],int]]:
|
|
y = (4,)
|
|
y = (4,)
|
|
return closure{1}({lambda_0}, x, y)
|
|
return closure{1}({lambda_0}, x, y)
|
|
|
|
|
|
def main() -> int:
|
|
def main() -> int:
|
|
- g = begin: clos_3 = closure{1}({f})
|
|
|
|
- clos_3[0](clos_3, 5)
|
|
|
|
- h = begin: clos_4 = closure{1}({f})
|
|
|
|
- clos_4[0](clos_4, 3)
|
|
|
|
|
|
+ g = (begin: clos_3 = closure{1}({f})
|
|
|
|
+ clos_3[0](clos_3, 5))
|
|
|
|
+ h = (begin: clos_4 = closure{1}({f})
|
|
|
|
+ clos_4[0](clos_4, 3))
|
|
print((begin: clos_5 = g
|
|
print((begin: clos_5 = g
|
|
- clos_5[0](clos_5, 11)
|
|
|
|
|
|
+ clos_5[0](clos_5, 11)
|
|
+ (begin: clos_6 = h
|
|
+ (begin: clos_6 = h
|
|
- clos_6[0](clos_6, 15))))
|
|
|
|
|
|
+ clos_6[0](clos_6, 15))))
|
|
return 0
|
|
return 0
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|