RosettaCodeData/Task/Apply-a-callback-to-an-array/OoRexx/apply-a-callback-to-an-array.rexx
2023-07-01 13:44:08 -04:00

24 lines
619 B
Rexx

start = .array~of("Rick", "Mike", "David", "Mark")
new = map(start, .routines~reversit)
call map new, .routines~sayit
-- a function to perform an iterated callback over an array
-- using the provided function. Returns an array containing
-- each function result
::routine map
use strict arg array, function
resultArray = .array~new(array~items)
do item over array
resultArray~append(function~call(item))
end
return resultArray
::routine reversit
use arg string
return string~reverse
::routine sayit
use arg string
say string
return .true -- called as a function, so a result is required