RosettaCodeData/Task/Higher-order-functions/Lingo/higher-order-functions-1.lingo
2023-07-01 13:44:08 -04:00

17 lines
515 B
Text

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