title: Different methods for determining whether a number is included in a given list
body: <p>Is it faster to check whether a number is equivalent to another, or to look up the number in a table?</p>
  
  <p>I have a program where commands sent from a server are received as numbers. Commands are sent frequently: anywhere from 1/second to 30+/second. Certain commands are ignored while others trigger various events. Would it be better to determine which event to trigger by doing this:</p>
  
  <pre><code>function incoming_integer(n)
    if n == 33 then
      print('a')
    elseif n == 44 then
      print('b')
    elseif n == 567 then
      print('c')
      ... (the actual list is occasionally pretty long: upwards of ten valid numbers)
    end
  end
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>functions = {
    [33] = function() print('a') end,
    [44] = function() print('b') end,
    [567] = function() print('c') end,
    ...
  }
  relevant_commands = {[33]= true, [44]=true, [567]=true ...}
  function incoming_integer(n)
    if relevant_commands[n] then
      functions[n]()
    end
  end
  </code></pre>
  
  <p>Is there a point at which one method becomes more efficient?
  What if the commands were instead sent as strings?</p>