Jeremy G. Siek 2 năm trước cách đây
mục cha
commit
ead4bdc502
1 tập tin đã thay đổi với 10 bổ sung10 xóa
  1. 10 10
      book.tex

+ 10 - 10
book.tex

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