Task

Pass a function     as an argument     to another function.



Related task

   First-class functions


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)
}
 