23 lines
411 B
Text
23 lines
411 B
Text
first = fn (F) {
|
|
F()
|
|
}
|
|
|
|
second = fn () {
|
|
io.format("hello~n")
|
|
}
|
|
|
|
@public
|
|
run = fn () {
|
|
# passing the function specifying the name and arity
|
|
# arity: the number of arguments it accepts
|
|
first(fn second:0)
|
|
|
|
first(fn () { io.format("hello~n") })
|
|
|
|
# holding a reference to the function in a variable
|
|
F1 = fn second:0
|
|
F2 = fn () { io.format("hello~n") }
|
|
|
|
first(F1)
|
|
first(F2)
|
|
}
|