85
will iterate over all lines of the file. When the iterator function detects the end of file, it returns
nil (to finishthe loop) and automatically closes the file.
The call io.lines() (with no file name) is equivalent to io.input():lines(); that is, it iterates over the
lines of the default input file. In this case it does not close the file when the loop ends.
io.open (filename [, mode])
This function opens a file, in the mode specified in the string mode. It returns a new file handle,
or, in case of errors, nil plus an error message. The mode string can be any of the following:
mode (the default);
end of file.
The mode string can also have a 'b' at the end, which is needed in some systems to open the
file in binary mode. This string is exactly what is used in the standard C function fopen.
io.output ([file])
Similar to io.input, but operates over the default output file.
6.1.27. Mathematical functions
This library is an interface to the standard C math library. It provides all its functions inside the
table math.
math.abs (x)
Returns the absolute value of x.
math.acos (x)
Returns the arc cosine of x (in radians).
math.asin (x)
Returns the arc sine of x (in radians).
math.atan (x)
Returns the arc tangent of x (in radians).
math.atan2 (y, x)
Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the
quadrant of the result. (It also handles correctly the case of x being zero.)
math.ceil (x)
Returns the smallest integer larger than or equal to x.
math.cos (x)