This gist is some study notes for Lua language.
Last active
August 29, 2015 14:08
-
-
Save terryoy/4a31df448932868284d5 to your computer and use it in GitHub Desktop.
lua study notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute a program | |
$ lua hello.lua | |
# import a file and then into interactive mode | |
$ lua -i lib.lua | |
# execute some line | |
$ lua -e "print(math.sin(12))" | |
# execute with library "a" (using "-l") | |
$ lua -i -l a -e "x = 10" | |
# execute with parameters ("p1 p2 p3") | |
$ lua script.lua p1 p2 p3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ now this is a comment ]]-- | |
--[[ | |
function useless_func() | |
end | |
]]-- | |
function norm(x, y) | |
return (x^2+y^2)^0.5 | |
end | |
function twice(x) | |
return 2*x | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Hello, world!") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ a uninitialized global variable ]]-- | |
print('this would be nil: b = ', b) | |
b = 10 | |
print('this would be 10: b = ', b) | |
--[[ an environment variable (using "lua>" as a prompt ]]-- | |
_PROMPT = "lua>" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment