math.max
math.max Function | |
---|---|
Syntax math.max(
| |
Returns | number |
API | math |
Source | Lua (source) |
Return the greatest of all the numbers given.
|
|||
Read as many lines as the user inputs, and return the greatest value that they wrote. | |||
Code | <nowiki>
local max = -(1/0) -- negative infinity
while true do
local l = read()
if tonumber(l) then
max = math.max(max, tonumber(l))
else
break
end
end
print(max)
</nowiki>
|
||
Output | The line the user wrote with the greatest value, or inf if they wrote no lines. |
Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Lua |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CC:Tweaked |
|
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.