Jump to content

min max value


Croqueta
 Share

Recommended Posts

esta funcion te da el value mas grande o menor de una tabla

function minmax(...)
local vmin,vmax
for i,v in ipairs{...} do
  if vmax==nil or v > vmax then
   vmax=v
  end
  if vmin==nil or v < vmin then
   vmin=v
  end
end
return vmin,vmax
end
vmin,vmax = minmax(4,1,6,1,8,5,8,3)
say(vmin,vmax)
say(vmin)
say(vmax)
result

 

>1 8
>1
>8
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...