title: How to have a function execute on a range of values in a Lua table
body: <p>I have a program that takes letters as input, finds their assigned number in a table, and runs some math operations on that number before giving the finished pair of numbers (the encoded letter) as an output. I have functions set up to check which character is inputted, and to run the math, but my code looks like this:</p>
  
  <pre><code>checkchar(chars[1])
  checkchar(chars[2])
  checkchar(chars[3])
  checkchar(chars[4])
  checkchar(chars[5])
  checkchar(chars[6])
  checkchar(chars[7])
  checkchar(chars[8])
  checkchar(chars[9])
  checkchar(chars[10])
  checkchar(chars[11])
  checkchar(chars[12])
  checkchar(chars[13])
  checkchar(chars[14])
  checkchar(chars[15])
  checkchar(chars[16])
  checkchar(chars[17])
  checkchar(chars[18])
  checkchar(chars[19])
  checkchar(chars[20])
  checkchar(chars[21])
  checkchar(chars[22])
  checkchar(chars[23])
  checkchar(chars[24])
  checkchar(chars[25])
  </code></pre>
  
  <p>Hardly efficient, plus it imposes a 25 character limit because I really don't want to paste this thing 100 times.</p>
  
  <p>Is there a way that I can have the program find the number of characters that have been inputted and use that number to decide how many values to run with the function, and then use that number again to print out just what was inputted so I don't have to print a bunch of black spaces?</p>