Higher-order functions: Difference between revisions

Content added Content deleted
Line 249: Line 249:
end filtered
end filtered


-- An ordinary AppleScript handler function

-- lifted into a script which is a first-class object
-- Inject a handler function into a script
-- to obtain a first class object with a call method
-- (a -> b) -> Script object
on mReturn(f)
on mReturn(f)
script mf
script
on call()
property call : f
end call
end script
end script
set mf's call to f
return mf
end mReturn
end mReturn



-- HANDLER FUNCTIONS TO BE PASSED AS ARGUMENTS
-- HANDLER FUNCTIONS TO BE PASSED AS ARGUMENTS