Task

Pass a function     as an argument     to another function.



Related task

   First-class functions


-- in some movie script
----------------------------------------
-- Runs provided function (of some object) on all elements of the provided list, returns results as new list
-- @param {list} aList
-- @param {symbol} cbFunc
-- @param {object} [cbObj=_movie]
-- @return {list}
----------------------------------------
on map (aList, cbFunc, cbObj)
  if voidP(cbObj) then cbObj = _movie
  res = []
  cnt = aList.count
  repeat with i = 1 to cnt
    res[i] = call(cbFunc, cbObj, aList[i])
  end repeat
  return res
end