Skip to content

patrickbucher/learning-lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Learning Lua

Using Programming in Lua (4th Edition)

Setup

Setup (Arch Linux):

$ sudo pacman -S lua luarocks

Usage

Interactive:

$ lua
> print("Hello, Lua!")

Script file (examples/hello.lua):

#!/usr/bin/env lua

print("Hello, Lua!")

Running the script file:

$ lua examples/hello.lua

$ chmod +x examples/hello.lua
$ examples/hello.lua

Loading the script file from an interactive session:

$ lua
> dofile("examples/hello.lua")

Run interactive session after executing a script:

$ lua -i examples/hello.lua
>

Example library script (examples/hypot.lua):

function hypot(a, b)
    return math.sqrt(a ^ 2 + b ^ 2)
end

Load library and execute an expression:

$ lua -l examples/hypot -e 'print(hypot(3, 4))'
5.0

Links

About

One (Small) Programming Language per Year

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages