kerkerj
Install lua on mac
I’m not sure that whether Lua is built on mac originally.
(Ok, tested on Mac OSX 10.9, there is Lua in it.)
So I installed Lua via Homebrew.
Install homebrew (optional)
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install Lua by homebrew
brew install lua
Writing Lua
You can use command: lua
to interact with lua. (just like php -a
or irb
)
print("Hello World")
function fact(n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
print("enter a number:")
num = io.read("*number")
print(fact(num))