반응형
1. 함수 사용방법
> factorial ( n )function fact (n)if n == 0 thenreturn 1elsereturn n * fact(n-1)endend
print("enter a number:")a = io.read("*number")print(fact(a))
> 여러 개의 함수 사용
function norm (x, y)local n2 = x^2 + y^2return math.sqrt(n2)endfunction twice (x)return 2*xendn = norm(3.4, 1.0)print(twice(n))
2. 문법의 가용성
> 가능
a = 1
b = a*2
> 가능
a = 1;
b = a*2;
> 가능
a = 1 ; b = a*2
> ugly, but valida = 1 b = a*2
반응형
'언어 > lua' 카테고리의 다른 글
6. 중간 정리 (0) | 2015.12.01 |
---|---|
5. 연산자 (0) | 2015.12.01 |
4. 자료형 (0) | 2015.12.01 |
2. 개발환경 세팅 (0) | 2015.12.01 |
1. Lua 설치 및 설정 (0) | 2015.12.01 |