LoginSignup
1
1

More than 5 years have passed since last update.

Writing Lua on Mac

Posted at

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))
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1