Run Lua Modules
Lesson 1 of 29 in Coddy's Lua for Luau Developers course.
This course assumes standalone Luau experience with functions, tables and metatables. The target is Lua 5.1, not a newer Lua release. Familiar core behavior lets us concentrate on syntax extensions, erased types, library availability and host boundaries. Run the supplied two-file program. main.lua is the locked entry point; it loads app.lua with require("app"). The editable module returns its public table. Later exercises keep this genuine module layout. Source examples use pure Luau computation; host-specific APIs are outside this course. The target driver handles input, so your modules work with an ordinary table of lines.
Challenge
BeginnerRun the supplied program. No edits or input are required. It returns Lua is ready.
Edit app.lua. The visible locked main.lua reads stdin into a sequence of lines, calls app.run(lines), and prints its returned value with one final newline. Do not print diagnostics or change the module names. Empty input gives an empty sequence. All numeric inputs are small enough to avoid overflow.
Try it yourself
local app = require("app")
local lines = {}
for line in io.lines() do lines[#lines + 1] = line end
print(app.run(lines))
All lessons in Lua for Luau Developers
1Syntax and Runtime
Run Lua ModulesInterpolation to TextFloor Division and NumbersBytes and UTF-8 LibrariesFalse Values and DefaultsConditional ExpressionsPractice on your own: Online Lua compiler