1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
include Rectangle from "./model.luck"
public function factorial(number)
local result = 1
# for - start from 0 to number - 1
for i in number
result *= (i + 1)
end
result
end
function recursive()
factorial(10) == 3628800
end
function with_return()
local factor = 0
if factor == 0
true
return
end
false
end
function first_class_function()
local f = factorial
f(10) == 3628800
end
function instance_first_class_function()
local rect = Rectangle(10, 20)
local a = rect.area
a() == 200
end