Scripting with StrongED
There is another way that RiscLua can be used, involving the text editor StrongED. In the smarticonbar of a StrongED window you may see the apply icon, as at the left. You can apply a Lua program to the text in a StrongED window by dragging it to the apply icon. SHIFT-drag replaces the text with the program's output, CTRL-drag opens a new window with the output in it, so that the old text is preserved. The program can read the text of the window it is dragged to by interpreting arg[1] as the name of a file containing it. For example:
  #! lua
  local used <const> = { }
  for line in io.lines (arg[1]) do
     if not used[line] then
         print (line)
         used[line] = true
     end -- if
   end -- for
has the effect of stripping out all repeated lines. Any initial line of a Lua program starting with # is treated as a comment. However StrongED can read this to know that the program is to be applied to the text in its window. The expression { } creates an empty table. The word local is not necessary for the working of this program but it is good practice to use local variables wherever possible. The expression <const> tells the interpreter that this local variable is read-only. The expression io.lines is an iterator that produces lines of text from a filename. If the line has not appeared already, it is output and recorded as a new index of the table. In Lua tables can be indexed by any non-nil value, not just integers. Note how square brackets are used to produce the value of a table at an index, and two consecutive minus signs indicate the start of a single-line comment. An undefined variable has the special value nil. After the words if, while, until, and, or, not , undefined variables count as false and all other values, apart from false, count as true. In particular, both the number zero and the empty string count as true.
The moral is that you are not restricted just to numbers as keys in a table. In Lua any non-nil value can be a valid key.