diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-05-05 16:21:57 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-05-05 16:21:57 -0300 |
| commit | 732741b62fe1cb9cf19ecca8b210474d076ba8b3 (patch) | |
| tree | 130a968e052996793bbdfbbe8e3a9bc6cac1f199 | |
| parent | cc0f635ef70c0a3f9e5359dee80978111b529864 (diff) | |
| download | lua-732741b62fe1cb9cf19ecca8b210474d076ba8b3.tar.gz lua-732741b62fe1cb9cf19ecca8b210474d076ba8b3.tar.bz2 lua-732741b62fe1cb9cf19ecca8b210474d076ba8b3.zip | |
cannot use (i=i+1)
| -rw-r--r-- | manual.tex | 14 |
1 files changed, 8 insertions, 6 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | % $Id: manual.tex,v 1.29 1999/04/07 16:40:04 roberto Exp roberto $ | 1 | % $Id: manual.tex,v 1.30 1999/04/14 20:47:12 roberto Exp roberto $ |
| 2 | 2 | ||
| 3 | \documentclass[11pt]{article} | 3 | \documentclass[11pt]{article} |
| 4 | \usepackage{fullpage,bnf} | 4 | \usepackage{fullpage,bnf} |
| @@ -41,7 +41,7 @@ Waldemar Celes | |||
| 41 | \tecgraf\ --- Computer Science Department --- PUC-Rio | 41 | \tecgraf\ --- Computer Science Department --- PUC-Rio |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | \date{{\small \tt\$Date: 1999/04/07 16:40:04 $ $}} | 44 | \date{{\small \tt\$Date: 1999/04/14 20:47:12 $ $}} |
| 45 | 45 | ||
| 46 | \maketitle | 46 | \maketitle |
| 47 | 47 | ||
| @@ -2152,10 +2152,11 @@ This function could be defined in Lua: | |||
| 2152 | \begin{verbatim} | 2152 | \begin{verbatim} |
| 2153 | function getn (t) | 2153 | function getn (t) |
| 2154 | if type(t.n) == 'number' then return t.n end | 2154 | if type(t.n) == 'number' then return t.n end |
| 2155 | local i = nil | ||
| 2156 | local max = 0 | 2155 | local max = 0 |
| 2157 | while (i=next(t, i)) do | 2156 | local i = next(t, nil) |
| 2157 | while i do | ||
| 2158 | if type(i) == 'number' and i>max then max=i end | 2158 | if type(i) == 'number' and i>max then max=i end |
| 2159 | i = next(t, i) | ||
| 2159 | end | 2160 | end |
| 2160 | return max | 2161 | return max |
| 2161 | end | 2162 | end |
| @@ -2198,10 +2199,11 @@ as the final value of \verb|foreachi|. | |||
| 2198 | This function could be defined in Lua: | 2199 | This function could be defined in Lua: |
| 2199 | \begin{verbatim} | 2200 | \begin{verbatim} |
| 2200 | function foreachi (t, f) | 2201 | function foreachi (t, f) |
| 2201 | local i, n = 0, getn(t) | 2202 | local i, n = 1, getn(t) |
| 2202 | while (i=i+1)<=n do | 2203 | while i <= n do |
| 2203 | local res = f(i, t[i]) | 2204 | local res = f(i, t[i]) |
| 2204 | if res then return res end | 2205 | if res then return res end |
| 2206 | i = i+1 | ||
| 2205 | end | 2207 | end |
| 2206 | end | 2208 | end |
| 2207 | \end{verbatim} | 2209 | \end{verbatim} |
