Jump to content




math.max from a table


  • You cannot reply to this topic
3 replies to this topic

#1 augustas656

  • Members
  • 158 posts

Posted 31 December 2013 - 11:06 PM

Does anyone know a very efficient and compact way of finding the highest number in a table that consists of number variables only? Especially this:
example = {}
example.A = 5
example.B = 15
example.C = 10
example.max = Formula that works out the highest number of all
the variables in the example table apart from this variable itself.

Thank you

Edited by augustas656, 31 December 2013 - 11:07 PM.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 31 December 2013 - 11:08 PM

math.max(unpack(example))

#3 augustas656

  • Members
  • 158 posts

Posted 31 December 2013 - 11:16 PM

Thank you, also, specifically I want to findout the most compact way of finding the highest text length from a table of strings only.

Edited by augustas656, 31 December 2013 - 11:20 PM.


#4 OReezy

  • Members
  • 91 posts

Posted 01 January 2014 - 12:21 AM

You can use # to get the length of strings and tables.

Ex: Length of strings
#stringVar
#table[1]

Ex: Length of table
#table

Edited by OReezy, 01 January 2014 - 12:23 AM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users