Higher-order functions: Difference between revisions

Line 199:
sing about "closures" by (hire for "Pipe Organ")</lang>
 
As we can see above, AppleScript functions (referred to as 'handlers' in Apple's documentation) are not, in themselves, first class objects. They can only be applied within anotherother functionfunctions, when passed as arguments, if wrapped in Script objects. If we abstract out this lifting of functions into objects by writing an '''mReturn''' or '''mInject''' function, we can then use it to write some higher-order functions which directly accept unadorned AppleScript handlers as arguments.
 
We could, for example, write '''map''', '''fold/reduce''' and '''filter''' functions for AppleScript as follows:
9,655

edits