RosettaCodeData/Task/Apply-a-callback-to-an-array/Phix/apply-a-callback-to-an-array.phix
2016-12-05 23:44:36 +01:00

13 lines
285 B
Text

function apply(integer f, sequence s)
-- apply function f to all elements of sequence s
for i = 1 to length(s) do
s[i] = call_func(f, {s[i]})
end for
return s
end function
function add1(integer x)
return x + 1
end function
? apply(routine_id("add1"),{1,2,3})